Preserve times on compression

This commit is contained in:
Con Kolivas 2016-10-17 21:25:36 +11:00
parent 5a5c5cd425
commit 64afd02a7d

11
lrzip.c
View file

@ -1246,6 +1246,11 @@ bool compress_file(rzip_control *control)
if (ENCRYPT) if (ENCRYPT)
release_hashes(control); release_hashes(control);
if (unlikely(!STDIN && !STDOUT && !preserve_times(control, fd_in))) {
fatal("Failed to preserve times on output file\n");
goto error;
}
if (unlikely(close(fd_in))) { if (unlikely(close(fd_in))) {
fatal("Failed to close fd_in\n"); fatal("Failed to close fd_in\n");
fd_in = -1; fd_in = -1;
@ -1264,8 +1269,10 @@ bool compress_file(rzip_control *control)
free(control->outfile); free(control->outfile);
return true; return true;
error: error:
if (STDIN && (fd_in > 0)) close(fd_in); if (STDIN && (fd_in > 0))
if ((!STDOUT) && (fd_out > 0)) close(fd_out); close(fd_in);
if ((!STDOUT) && (fd_out > 0))
close(fd_out);
return false; return false;
} }