summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/contrib/fileutl.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index f86bf2942..91aecee65 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/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);