]> git.saurik.com Git - apt.git/blobdiff - methods/copy.cc
merged from lp:~donkult/apt/experimental
[apt.git] / methods / copy.cc
index d737e3c33cb851b646d726c24f00fad053098cce..94467e054c7e5f687fa1fd36fa287d82580ba232 100644 (file)
@@ -9,9 +9,12 @@
    ##################################################################### */
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
+#include <config.h>
+
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/acquire-method.h>
 #include <apt-pkg/error.h>
+#include <apt-pkg/hashes.h>
 
 #include <sys/stat.h>
 #include <utime.h>
@@ -51,7 +54,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)
    {
@@ -79,6 +82,11 @@ bool CopyMethod::Fetch(FetchItem *Itm)
       return _error->Errno("utime",_("Failed to set modification time"));
    }
    
+   Hashes Hash;
+   FileFd Fd(Res.Filename, FileFd::ReadOnly);
+   Hash.AddFD(Fd.Fd(), Fd.Size());
+   Res.TakeHashes(Hash);
+
    URIDone(Res);
    return true;
 }