From 8a698c5c6b5bd6720113689b36e9881da0cc9ebb Mon Sep 17 00:00:00 2001 From: dockes Date: Thu, 15 Jan 2009 17:07:09 +0000 Subject: [PATCH] fixed handling of decompression errors, which was wrong but not catastrophly so in most cases --- src/filters/rcluncomp | 4 ++-- src/internfile/internfile.cpp | 14 +++++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/filters/rcluncomp b/src/filters/rcluncomp index 269b4567..a08777b4 100755 --- a/src/filters/rcluncomp +++ b/src/filters/rcluncomp @@ -21,11 +21,11 @@ sinfile=`basename "$infile"` case "$sinfile" in *.*) cp "$infile" "$outdir/$sinfile" || exit 1 - $uncomp "$outdir/$sinfile" + $uncomp "$outdir/$sinfile" || exit 1 uncompressed=`echo $outdir/*` ;; *) - $uncomp < "$infile" > "$outdir/$sinfile" + $uncomp < "$infile" > "$outdir/$sinfile" || exit 1 uncompressed="$outdir/$sinfile" ;; esac diff --git a/src/internfile/internfile.cpp b/src/internfile/internfile.cpp index f46f64d4..1060aa26 100644 --- a/src/internfile/internfile.cpp +++ b/src/internfile/internfile.cpp @@ -102,8 +102,11 @@ static bool uncompressfile(RclConfig *conf, const string& ifn, ExecCmd ex; int status = ex.doexec(cmd, args, 0, &tfile); if (status || tfile.empty()) { - LOGERR(("uncompressfile: doexec: failed for [%s] status 0x%x\n", ifn.c_str(), status)); - rmdir(tdir.c_str()); + LOGERR(("uncompressfile: doexec: failed for [%s] status 0x%x\n", + ifn.c_str(), status)); + if (wipedir(tdir.c_str())) { + LOGERR(("uncompressfile: wipedir failed\n")); + } return false; } if (tfile[tfile.length() - 1] == '\n') @@ -619,7 +622,7 @@ FileInterner::Status FileInterner::internfile(Rcl::Doc& doc, string& ipath) return FIAgain; } - +// Automatic cleanup of iDocTempFile's temp dir class DirWiper { public: string dir; @@ -637,6 +640,11 @@ class DirWiper { // We do the usual internfile stuff: create a temporary directory, // then create an interner and call internfile. // We then write the data out of the resulting document into the output file. +// There are two temporary objects: +// - The internfile temporary directory gets destroyed before we +// return by the DirWiper object +// - The output temporary file which is held in a reference-counted +// object and will be deleted when done with. bool FileInterner::idocTempFile(TempFile& otemp, RclConfig *cnf, const string& fn, const string& ipath,