apt-pkg, methods: Convert users of WriteEmpty to WriteAtomic.
authorJulian Andres Klode <jak@debian.org>
Tue, 10 Aug 2010 12:59:56 +0000 (14:59 +0200)
committerJulian Andres Klode <jak@debian.org>
Tue, 10 Aug 2010 12:59:56 +0000 (14:59 +0200)
apt-pkg/depcache.cc
apt-pkg/indexcopy.cc
apt-pkg/pkgcachegen.cc
debian/changelog
methods/bzip2.cc
methods/copy.cc
methods/gzip.cc
methods/rred.cc

index 043185d..00bf68a 100644 (file)
@@ -227,7 +227,7 @@ bool pkgDepCache::writeStateFile(OpProgress *prog, bool InstalledOnly)      /*{{{*/
    // if it does not exist, create a empty one
    if(!FileExists(state)) 
    {
-      StateFile.Open(state, FileFd::WriteEmpty);
+      StateFile.Open(state, FileFd::WriteAtomic);
       StateFile.Close();
    }
 
index 621c187..b4e587d 100644 (file)
@@ -134,7 +134,7 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector<string> &List,
       TargetF += URItoFileName(S);
       if (_config->FindB("APT::CDROM::NoAct",false) == true)
         TargetF = "/dev/null";
-      FileFd Target(TargetF,FileFd::WriteEmpty);
+      FileFd Target(TargetF,FileFd::WriteAtomic);
       FILE *TargetFl = fdopen(dup(Target.Fd()),"w");
       if (_error->PendingError() == true)
         return false;
@@ -565,7 +565,7 @@ bool SigVerify::CopyMetaIndex(string CDROM, string CDName,          /*{{{*/
 
       FileFd Target;
       FileFd Rel;
-      Target.Open(TargetF,FileFd::WriteEmpty);
+      Target.Open(TargetF,FileFd::WriteAtomic);
       Rel.Open(prefix + file,FileFd::ReadOnly);
       if (_error->PendingError() == true)
         return false;
@@ -840,7 +840,7 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name,   /*{{{*/
       TargetF += URItoFileName(S);
       if (_config->FindB("APT::CDROM::NoAct",false) == true)
         TargetF = "/dev/null";
-      FileFd Target(TargetF,FileFd::WriteEmpty);
+      FileFd Target(TargetF,FileFd::WriteAtomic);
       FILE *TargetFl = fdopen(dup(Target.Fd()),"w");
       if (_error->PendingError() == true)
         return false;
index c9a9a75..ed35174 100644 (file)
@@ -1192,7 +1192,7 @@ bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress
    if (Writeable == true && CacheFile.empty() == false)
    {
       unlink(CacheFile.c_str());
-      CacheF = new FileFd(CacheFile,FileFd::WriteEmpty);
+      CacheF = new FileFd(CacheFile,FileFd::WriteAtomic);
       fchmod(CacheF->Fd(),0644);
       Map = CreateDynamicMMap(CacheF, MMap::Public);
       if (_error->PendingError() == true)
@@ -1254,7 +1254,7 @@ bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress
       // Write it back
       if (Writeable == true && SrcCacheFile.empty() == false)
       {
-        FileFd SCacheF(SrcCacheFile,FileFd::WriteEmpty);
+        FileFd SCacheF(SrcCacheFile,FileFd::WriteAtomic);
         if (_error->PendingError() == true)
            return false;
         
index 0f3d0d4..6945b48 100644 (file)
@@ -12,6 +12,8 @@ apt (0.7.26~exp13) UNRELEASEDexperimental; urgency=low
   * apt-pkg/contrib/fileutl.cc:
     - Add WriteAtomic mode.
     - Revert WriteEmpty to old behavior (LP: #613211)
+  * apt-pkg, methods:
+    - Convert users of WriteEmpty to WriteAtomic.
   * apt-pkg/depcache.cc:
     - Only try upgrade for Breaks if there is a newer version, otherwise
       handle it as Conflicts (by removing it) (helps for #591882).
index 5da214b..19e4982 100644 (file)
@@ -91,7 +91,7 @@ bool Bzip2Method::Fetch(FetchItem *Itm)
    close(GzOut[1]);
    
    FileFd FromGz(GzOut[0]);  // For autoclose   
-   FileFd To(Itm->DestFile,FileFd::WriteEmpty);   
+   FileFd To(Itm->DestFile,FileFd::WriteAtomic);   
    To.EraseOnFailure();
    if (_error->PendingError() == true)
       return false;
index 027b59f..a6bb372 100644 (file)
@@ -52,7 +52,7 @@ bool CopyMethod::Fetch(FetchItem *Itm)
    
    // See if the file exists
    FileFd From(File,FileFd::ReadOnly);
-   FileFd To(Itm->DestFile,FileFd::WriteEmpty);
+   FileFd To(Itm->DestFile,FileFd::WriteAtomic);
    To.EraseOnFailure();
    if (_error->PendingError() == true)
    {
index 72e3ac9..5b9b66b 100644 (file)
@@ -55,7 +55,7 @@ bool GzipMethod::Fetch(FetchItem *Itm)
       return true;
    }
 
-   FileFd To(Itm->DestFile,FileFd::WriteEmpty);   
+   FileFd To(Itm->DestFile,FileFd::WriteAtomic);   
    To.EraseOnFailure();
    if (_error->PendingError() == true)
       return false;
index f42c7a0..d51c45c 100644 (file)
@@ -446,7 +446,7 @@ bool RredMethod::Fetch(FetchItem *Itm)                                              /*{{{*/
    // the cleanup/closing of the fds)
    FileFd From(Path,FileFd::ReadOnly);
    FileFd Patch(Path+".ed",FileFd::ReadOnly);
-   FileFd To(Itm->DestFile,FileFd::WriteEmpty);   
+   FileFd To(Itm->DestFile,FileFd::WriteAtomic);   
    To.EraseOnFailure();
    if (_error->PendingError() == true)
       return false;
@@ -458,7 +458,7 @@ bool RredMethod::Fetch(FetchItem *Itm)                                              /*{{{*/
       // retry with patchFile
       lseek(Patch.Fd(), 0, SEEK_SET);
       lseek(From.Fd(), 0, SEEK_SET);
-      To.Open(Itm->DestFile,FileFd::WriteEmpty);
+      To.Open(Itm->DestFile,FileFd::WriteAtomic);
       if (_error->PendingError() == true)
          return false;
       if (patchFile(Patch, From, To, &Hash) != ED_OK) {