Explorar o código

apt-pkg/contrib/fileutl.cc: Revert WriteEmpty to old behavior (LP: #613211)

Julian Andres Klode %!s(int64=16) %!d(string=hai) anos
pai
achega
fc81e8f2de
Modificáronse 2 ficheiros con 9 adicións e 1 borrados
  1. 8 1
      apt-pkg/contrib/fileutl.cc
  2. 1 0
      debian/changelog

+ 8 - 1
apt-pkg/contrib/fileutl.cc

@@ -670,7 +670,6 @@ bool FileFd::Open(string FileName,OpenMode Mode, unsigned long Perms)
       break;
       
       case WriteAtomic:
-      case WriteEmpty:
       {
 	 Flags |= Replace;
 	 char *name = strdup((FileName + ".XXXXXX").c_str());
@@ -680,6 +679,14 @@ bool FileFd::Open(string FileName,OpenMode Mode, unsigned long Perms)
 	 break;
       }
 
+      case WriteEmpty:
+      {
+      	 struct stat Buf;
+	 if (lstat(FileName.c_str(),&Buf) == 0 && S_ISLNK(Buf.st_mode))
+	    unlink(FileName.c_str());
+	 iFd = open(FileName.c_str(),O_RDWR | O_CREAT | O_TRUNC,Perms);
+	 break;
+      }
       
       case WriteExists:
       iFd = open(FileName.c_str(),O_RDWR);

+ 1 - 0
debian/changelog

@@ -11,6 +11,7 @@ apt (0.7.26~exp13) UNRELEASEDexperimental; urgency=low
   [ Julian Andres Klode ]
   * apt-pkg/contrib/fileutl.cc:
     - Add WriteAtomic mode.
+    - Revert WriteEmpty to old behavior (LP: #613211)
   * 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).