From 4b5f735fad8be7feb0ca53dcdba80f7b2c665fd8 Mon Sep 17 00:00:00 2001 From: Michael Vrable Date: Mon, 21 Oct 2013 10:02:17 -0700 Subject: [PATCH] Fix output file size estimation. When piping output through a filter (for compression/encryption), we need to keep the underlying file descriptor open so we can check the output file size. Previously it was being closed too early so Tarfile::size_estimate was failing. --- store.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/store.cc b/store.cc index 0b03493..ba6d692 100644 --- a/store.cc +++ b/store.cc @@ -96,7 +96,6 @@ FileFilter *FileFilter::New(int fd, const char *program) pid_t pid; int wrapped_fd = spawn_filter(fd, program, &pid); - close(fd); return new FileFilter(fd, wrapped_fd, pid); } @@ -106,6 +105,10 @@ int FileFilter::wait() if (pid == -1) return 0; + // The raw file descriptor was held open to track the output file size, but + // is not needed any longer. + close(fd_raw); + int status; if (waitpid(pid, &status, 0) < 0) { fprintf(stderr, "Error waiting for filter process: %m\n"); -- 2.20.1