]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/contrib/fileutl.cc
give a descriptive error for pipe tries with 'false'
[apt.git] / apt-pkg / contrib / fileutl.cc
index 6bfa5ca9285ffd7ff2e572c682930531efed16ca..c623f1a2a5bbac58d2b6c264d04018f76db7b5e4 100644 (file)
@@ -1535,7 +1535,7 @@ public:
         return false;
 
       unsigned int flags = (Mode & (FileFd::WriteOnly|FileFd::ReadOnly));
-      if (backend.OpenDescriptor(iFd, flags) == false)
+      if (backend.OpenDescriptor(iFd, flags, FileFd::None, true) == false)
         return false;
 
       // Write the file header
@@ -1646,6 +1646,11 @@ public:
         res = LZ4F_freeDecompressionContext(dctx);
         dctx = nullptr;
       }
+      if (backend.IsOpen())
+      {
+        backend.Close();
+        filefd->iFd = -1;
+      }
 
       return LZ4F_isError(res) == false;
    }
@@ -1877,6 +1882,9 @@ public:
 
       if ((Mode & FileFd::ReadWrite) == FileFd::ReadWrite)
         return filefd->FileFdError("ReadWrite mode is not supported for file %s", filefd->FileName.c_str());
+      if (compressor.Binary == "false")
+        return filefd->FileFdError("libapt has inbuilt support for the %s compression,"
+              " but was forced to ignore it in favor of an external binary – which isn't installed.", compressor.Name.c_str());
 
       bool const Comp = (Mode & FileFd::WriteOnly) == FileFd::WriteOnly;
       if (Comp == false)
@@ -2618,7 +2626,7 @@ bool FileFd::Close()
    }
 
    if ((Flags & Replace) == Replace) {
-      if (rename(TemporaryFileName.c_str(), FileName.c_str()) != 0)
+      if (Failed() == false && rename(TemporaryFileName.c_str(), FileName.c_str()) != 0)
         Res &= _error->Errno("rename",_("Problem renaming the file %s to %s"), TemporaryFileName.c_str(), FileName.c_str());
 
       FileName = TemporaryFileName; // for the unlink() below.