Hi,

i identified a better candidate for detecting non-matching FilePart objects
during scanning. (I learned that jigdo-lite downloads 10 files and then lets
jigdo-file make a scan over the whole image in order to find the places
where they fit. Is this done because jigdo-file has no idea of downloading ?)

The included experimental changeset demonstrates a fallback check. Nevertheless
it seems necessary to verify the package files after downloading, not deep
in the course of image reconstruction.

The ichangeset is not yet intended for production.
(At least the macro SIMULATE_TRIGGER_OF_DEBIAN_BUG_884526 should get
 undefined, my "ts B712.." marks and surplus empty lines should get removed.)

============================================================================
--- src/scan.hh.orig    2017-12-16 16:24:10.297866522 +0100
+++ src/scan.hh 2017-12-17 10:58:25.354118956 +0100
@@ -100,6 +100,10 @@ public:
       failed, or other reasons. */
   bool deleted() const { return fileSize == 0; }
 
+  // ts B71217 : Experimental
+  void markAsFoundInCache();
+  bool wasFoundInCache();
+
   /** Do not call - this is public only because list<> must be able to
       delete FileParts */
   ~FilePart() { }
@@ -151,6 +155,12 @@ private:
     WAS_LOOKED_UP = 2,
     // Write this file's info into the cache file during ~JigdoCache()
     TO_BE_WRITTEN = 4
+
+    ,
+    // ts B71216 : Experimental
+    // This file in the cache was found as matching the MD5 of a template part
+    WAS_FOUND_IN_CACHE = 8
+
   };
   Flags flags;
   bool getFlag(Flags f) const { return (flags & f) != 0; }
--- src/scan.cc.orig    2017-12-17 10:35:36.214113786 +0100
+++ src/scan.cc 2017-12-17 10:56:22.358118491 +0100
@@ -490,3 +490,17 @@ void JigdoCache::addFile(const string& n
   FilePart fp(i, nameRest, fileInfo.st_size, fileInfo.st_mtime);
   files.push_back(fp);
 }
+//______________________________________________________________________
+
+// ts B71217 : Experimental
+void FilePart::markAsFoundInCache() {
+  setFlag(WAS_FOUND_IN_CACHE);
+}
+//______________________________________________________________________
+
+// ts B71217 : Experimental
+bool FilePart::wasFoundInCache() {
+  return getFlag(WAS_FOUND_IN_CACHE);
+}
+//______________________________________________________________________
+
--- src/mkimage.cc.orig 2017-12-16 16:24:10.297866522 +0100
+++ src/mkimage.cc      2017-12-17 12:13:26.850135952 +0100
@@ -817,11 +817,31 @@ int JigdoDesc::makeImage(JigdoCache* cac
     while (ci != ce) {
       // The call to getMD5Sum() may cause the whole file to be read!
       const MD5Sum* md = ci->getMD5Sum(cache);
+
+#define SIMULATE_TRIGGER_OF_DEBIAN_BUG_884526 yes
+#ifdef SIMULATE_TRIGGER_OF_DEBIAN_BUG_884526
+
+      // ts B71217 : Experimental : Fake failure in debian-6.0.7-amd64-netinst
+      if (strstr(ci->leafName().c_str(), "partman-reiserfs_50_all.udeb")
+          != NULL) {
+        reporter.info(_(""));
+        reporter.info(_("ATTENTION : Faking a checksum mismatch with "
+                        "package `partman-reiserfs_50_all.udeb'"));
+        ++ci;
+    continue;
+      }
+
+#endif /* SIMULATE_TRIGGER_OF_DEBIAN_BUG_884526 */
+
       if (md != 0 && *md == m->md5()) {
         toCopy.push(&*ci); // Found matching file
         totalBytes += m->size();
         debug("%1 found, pushed %2", m->md5().toString(), &*ci);
         found = true;
+
+        // ts B71217 : Experimental
+        ci->markAsFoundInCache();
+
         break;
       }
       ++ci;
@@ -831,6 +851,23 @@ int JigdoDesc::makeImage(JigdoCache* cac
   }
   //____________________
 
+
+  // ts B71217 : Experimental
+  // Warn about cache files which were not used during the scan
+  ci = cache->begin();
+  while (ci != ce) {
+    if (!ci->wasFoundInCache()) {
+      reporter.info(_(""));
+      reporter.info(_("POSSIBLE FILE CORRUPTION: "
+                      "Downloaded file did not fit into the template."));
+      string warn_text = subst(_("POSSIBLY CORRUPTED: `%1'"), ci->leafName());
+      reporter.info(warn_text);
+      reporter.info(_(""));
+    }
+    ++ci;
+  }
+
+
   debug("JigdoDesc::mkImage: %1 missing, %2 found for copying to image, "
         "%3 entries in template", missing, toCopy.size(), files.size());
 
============================================================================

When i use this jigdo-file with jigdo-lite and these three input lines
  
[http://cdimage.debian.org/cdimage/archive/6.0.7/amd64/jigdo-cd/debian-6.0.7-amd64-netinst.jigdo

  http://us.cdimage.debian.org/cdimage/snapshot/Debian/
then i get these messages

  ATTENTION : Faking a checksum mismatch with package 
`partman-reiserfs_50_all.udeb'

  POSSIBLE FILE CORRUPTION: Downloaded file did not fit into the template.
  POSSIBLY CORRUPTED: 
`debian-6.0.7-amd64-netinst.iso.tmpdir/us.cdimage.debian.org/cdimage/snapshot/Debian/pool/main/p/partman-reiserfs/partman-reiserfs_50_all.udeb'

  ...
  -----------------------------------------------------------------
  Aaargh - 1 files could not be downloaded.

The message part with the package file name can still be improved.
But i already learned more about C++ today than i ever wanted to know.


I will try to find a good spot in jigdo-lite where the freshly downloaded
package can be compared with the checksum (from the .jigdo file ?).


Have a nice day :)

Thomas

Reply via email to