summaryrefslogtreecommitdiff
path: root/methods/rred.cc
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2010-09-03 14:04:50 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2010-09-03 14:04:50 +0200
commit0205540433440a9ff4ad4ea4cce44c700a4b401c (patch)
tree97809e2e38482d3d7f124b30552a0936adf4d405 /methods/rred.cc
parent24baab5c477bf1e57a0b169a7bac1d2e9ab0c974 (diff)
parent2c6baa5a1f935eb3b8d4eb9fdef62e696416e27a (diff)
merged from lp:~donkult/apt/sid
Diffstat (limited to 'methods/rred.cc')
-rw-r--r--methods/rred.cc23
1 files changed, 13 insertions, 10 deletions
diff --git a/methods/rred.cc b/methods/rred.cc
index 262c78cab..d51c45c85 100644
--- a/methods/rred.cc
+++ b/methods/rred.cc
@@ -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) {
@@ -477,23 +477,26 @@ bool RredMethod::Fetch(FetchItem *Itm) /*{{{*/
Patch.Close();
To.Close();
- // Transfer the modification times
- struct stat Buf;
- if (stat(Path.c_str(),&Buf) != 0)
+ /* Transfer the modification times from the patch file
+ to be able to see in which state the file should be
+ and use the access time from the "old" file */
+ struct stat BufBase, BufPatch;
+ if (stat(Path.c_str(),&BufBase) != 0 ||
+ stat(string(Path+".ed").c_str(),&BufPatch) != 0)
return _error->Errno("stat",_("Failed to stat"));
struct utimbuf TimeBuf;
- TimeBuf.actime = Buf.st_atime;
- TimeBuf.modtime = Buf.st_mtime;
+ TimeBuf.actime = BufBase.st_atime;
+ TimeBuf.modtime = BufPatch.st_mtime;
if (utime(Itm->DestFile.c_str(),&TimeBuf) != 0)
return _error->Errno("utime",_("Failed to set modification time"));
- if (stat(Itm->DestFile.c_str(),&Buf) != 0)
+ if (stat(Itm->DestFile.c_str(),&BufBase) != 0)
return _error->Errno("stat",_("Failed to stat"));
// return done
- Res.LastModified = Buf.st_mtime;
- Res.Size = Buf.st_size;
+ Res.LastModified = BufBase.st_mtime;
+ Res.Size = BufBase.st_size;
Res.TakeHashes(Hash);
URIDone(Res);