]> git.saurik.com Git - apt.git/commitdiff
* bugfix/updates in the rred.cc code (big thanks for helping Robert!)
authorMichael Vogt <michael.vogt@ubuntu.com>
Mon, 22 Aug 2005 10:19:43 +0000 (10:19 +0000)
committerMichael Vogt <michael.vogt@ubuntu.com>
Mon, 22 Aug 2005 10:19:43 +0000 (10:19 +0000)
apt-pkg/acquire-item.cc
debian/changelog
methods/rred.cc

index 43d29c737567e8ca36b86a88f5aa52017f548d1d..b8886a750aafa84ee5dc178a84bb55f0c9a5c2cb 100644 (file)
@@ -255,6 +255,7 @@ void pkgAcqIndexDiffs::Finish(bool allDone)
 
 bool pkgAcqIndexDiffs::QueueNextDiff()
 {
+
    // calc sha1 of the just patched file
    string FinalFile = _config->FindDir("Dir::State::lists");
    FinalFile += URItoFileName(RealURI);
@@ -263,6 +264,9 @@ bool pkgAcqIndexDiffs::QueueNextDiff()
    SHA1Summation SHA1;
    SHA1.AddFD(fd.Fd(), fd.Size());
    string local_sha1 = string(SHA1.Result());
+   if(Debug)
+      std::clog << "QueueNextDiff: " 
+               << FinalFile << " (" << local_sha1 << ")"<<std::endl;
 
    // remove all patches until the next matching patch is found
    // this requires the Index file to be ordered
index 614041acf70d7b0dd6bf214e8453a68b906741ca..fa1e88244f686baccbbeb0c8fc9cb33384e44455 100644 (file)
@@ -4,7 +4,7 @@ apt (0.6.40.2) unstable; urgency=low
     dpkg, added the format to README.progress-reporting
   * added README.progress-reporting to the apt-doc package
 
- --
+ -- 
 
 apt (0.6.40.1) unstable; urgency=low
 
index 3097fca022517ca6a90876ee1302b1cd34f1d0e3..ab73398f512d9b66a84d7ca8f2c8440aae65aaab 100644 (file)
@@ -25,15 +25,17 @@ class RredMethod : public pkgAcqMethod
 
 #define BUF_SIZE       (1024)
 
-// XX use enums
+// XXX use enums
 #define MODE_CHANGED   0
 #define MODE_DELETED   1
 #define MODE_ADDED             2
 
+#define ED_OK                   0
 #define ED_ORDERING            1
 #define ED_PARSER              2
 #define ED_FAILURE             3
 
+// XXX someone better go out and understand the error reporting/handling here...
 int ed_rec(FILE *ed_cmds, FILE *in_file, FILE *out_file, int line, 
                char *buffer, unsigned int bufsize, Hashes *hash) {
        int pos;
@@ -154,8 +156,7 @@ int ed_file(FILE *ed_cmds, FILE *in_file, FILE *out_file, Hashes *hash) {
        if (result > 0) {
                while (fgets(buffer, BUF_SIZE, in_file) != NULL) {
                        written = fwrite(buffer, 1, strlen(buffer), out_file);
-                       // XXX add to hash
-                       // sha_process_bytes(buffer, written, &sha);
+                       hash->Add((unsigned char*)buffer, written);
                }
        }
        else {
@@ -163,7 +164,7 @@ int ed_file(FILE *ed_cmds, FILE *in_file, FILE *out_file, Hashes *hash) {
                fprintf(stderr, "Error: %i\n", result);
                return ED_FAILURE;
        }
-       return 0;
+       return ED_OK;
 }
 
 
@@ -192,13 +193,38 @@ bool RredMethod::Fetch(FetchItem *Itm)
    FILE* fPatch = fdopen(Patch.Fd(), "r");
    FILE* fTo = fdopen(To.Fd(), "w");
    // now do the actual patching
-   ed_file(fPatch, fFrom, fTo, &Hash);
-
-   // XXX need to get the size 
-   // Res.Size = Buf.st_size;
+   if (ed_file(fPatch, fFrom, fTo, &Hash) != ED_OK) {
+      return false;
+   }
+
+   // write out the result
+   fflush(fFrom);
+   fflush(fPatch);
+   fflush(fTo);
+   From.Close();
+   Patch.Close();
+   To.Close();
+
+   // Transfer the modification times
+   struct stat Buf;
+   if (stat(Path.c_str(),&Buf) != 0)
+      return _error->Errno("stat",_("Failed to stat"));
+
+   struct utimbuf TimeBuf;
+   TimeBuf.actime = Buf.st_atime;
+   TimeBuf.modtime = Buf.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)
+      return _error->Errno("stat",_("Failed to stat"));
+
+   // return done
+   Res.LastModified = Buf.st_mtime;
+   Res.Size = Buf.st_size;
    Res.TakeHashes(Hash);
    URIDone(Res);
-   
+
    return true;
 }
                                                                        /*}}}*/