summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2005-08-22 10:19:43 +0000
committerMichael Vogt <michael.vogt@ubuntu.com>2005-08-22 10:19:43 +0000
commit3de9ff77a811d67632c9948a953e628ed6a2b78a (patch)
tree4ab2fc3f7f4be11c6343f2124ce1a74462f5a4a7
parent59a704f0efe9cf243f1b27ac833558b89728aa9c (diff)
* bugfix/updates in the rred.cc code (big thanks for helping Robert!)
-rw-r--r--apt-pkg/acquire-item.cc4
-rw-r--r--debian/changelog2
-rw-r--r--methods/rred.cc44
3 files changed, 40 insertions, 10 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index 43d29c737..b8886a750 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -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
diff --git a/debian/changelog b/debian/changelog
index 614041acf..fa1e88244 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -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
diff --git a/methods/rred.cc b/methods/rred.cc
index 3097fca02..ab73398f5 100644
--- a/methods/rred.cc
+++ b/methods/rred.cc
@@ -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;
}
/*}}}*/