From 4a9db82795a64fce22128f8dc06596421ce2d865 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 10 Aug 2010 14:53:12 +0200 Subject: apt-pkg/contrib/fileutl.cc: Add WriteAtomic mode. --- apt-pkg/contrib/fileutl.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'apt-pkg/contrib/fileutl.cc') diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 2a3b8a87d..f86bf2942 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -669,6 +669,7 @@ bool FileFd::Open(string FileName,OpenMode Mode, unsigned long Perms) } break; + case WriteAtomic: case WriteEmpty: { Flags |= Replace; @@ -678,6 +679,7 @@ bool FileFd::Open(string FileName,OpenMode Mode, unsigned long Perms) free(name); break; } + case WriteExists: iFd = open(FileName.c_str(),O_RDWR); -- cgit v1.2.3 From fc81e8f2deff3b86738cad78aa491b1b514b3c59 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 10 Aug 2010 14:55:36 +0200 Subject: apt-pkg/contrib/fileutl.cc: Revert WriteEmpty to old behavior (LP: #613211) --- apt-pkg/contrib/fileutl.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'apt-pkg/contrib/fileutl.cc') 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); -- cgit v1.2.3