jc.rescan();
}
- set<MD5> sums;
+ set<MD5> MD5sums;
+ set<SHA256> SHA256sums;
try {
- JigdoDesc::listMissing(sums, imageTmpFile, templFile, templ,
- *optReporter);
+ JigdoDesc::listMissingMD5(MD5sums, imageTmpFile, templFile, templ,
+ *optReporter);
+ JigdoDesc::listMissingSHA256(SHA256sums, imageTmpFile, templFile, templ,
+ *optReporter);
} catch (Error e) {
string err = subst(_("%1 print-missing: %2"), binaryName, e.message);
optReporter->error(err);
case PRINT_MISSING: {
// To list just the first URI
- for (set<MD5>::iterator i = sums.begin(), e = sums.end(); i != e; ++i) {
+ for (set<MD5>::iterator i = MD5sums.begin(), e = MD5sums.end(); i != e; ++i) {
Base64String m;
m.write(i->sum, 16).flush();
string& s(m.result());
printMissing_lookup(jc, s, false);
}
}
+
+ // To list just the first URI
+ for (set<SHA256>::iterator i = SHA256sums.begin(), e = SHA256sums.end(); i != e; ++i) {
+ Base64String m;
+ m.write(i->sum, 32).flush();
+ string& s(m.result());
+
+ vector<string> words;
+ size_t off;
+ bool found = false;
+ for (ConfigFile::Find f(cf, partsSection, s, &off);
+ !f.finished(); off = f.next()) {
+ // f.section() points to "[section]" line, or end() if 0th section
+ // f.label() points to "label=..." line, or end() if f.finished()
+ // off is offset of part after "label=", or 0
+ words.clear();
+ ConfigFile::split(words, *f.label(), off);
+ // Ignore everything but the first word
+ if (printMissing_lookup(jc, words[0], false)) { found = true; break;}
+ }
+ if (!found) {
+ /* No mapping found in [Parts] (this shouldn't happen) - create
+ fake "SHA256sum:<sha256sum>" label line */
+ s.insert(0, "SHA256Sum:");
+ printMissing_lookup(jc, s, false);
+ }
+ }
break;
}
case PRINT_MISSING_ALL: {
// To list all URIs for each missing file, separated by empty lines:
- for (set<MD5>::iterator i = sums.begin(), e = sums.end(); i != e; ++i){
+ for (set<MD5>::iterator i = MD5sums.begin(), e = MD5sums.end(); i != e; ++i){
Base64String m;
m.write(i->sum, 16).flush();
string& s(m.result());
printMissing_lookup(jc, s, true);
cout << endl;
}
+ for (set<SHA256>::iterator i = SHA256sums.begin(), e = SHA256sums.end(); i != e; ++i){
+ Base64String m;
+ m.write(i->sum, 32).flush();
+ string& s(m.result());
+
+ vector<string> words;
+ size_t off;
+ for (ConfigFile::Find f(cf, partsSection, s, &off);
+ !f.finished(); off = f.next()) {
+ // f.section() points to "[section]" line, or end() if 0th section
+ // f.label() points to "label=..." line, or end() if f.finished()
+ // off is offset of part after "label=", or 0
+ words.clear();
+ ConfigFile::split(words, *f.label(), off);
+ // Ignore everything but the first word
+ printMissing_lookup(jc, words[0], true);
+ }
+ // Last resort: "SHA256sum:<sha256sum>" label line
+ s.insert(0, "SHA256Sum:");
+ printMissing_lookup(jc, s, true);
+ cout << endl;
+ }
break;
}
JigdoCache::iterator ci = cache.begin(), ce = cache.end();
if (optScanWholeFile) {
// Cause entire file to be read
- while (ci != ce) { ci->getMD5Sum(&cache); ++ci; }
+ while (ci != ce) {
+ ci->getMD5Sum(&cache);
+ ci->getSHA256Sum(&cache);
+ ++ci;
+ }
} else {
- // Only cause first md5 block to be read; not scanning the whole file
- while (ci != ce) { ci->getMD5Sums(&cache, 0); ++ci; }
+ // Only cause first checksum block to be read; not scanning the whole file
+ while (ci != ce) {
+ ci->getMD5Sums(&cache, 0);
+ ci->getSHA256Sums(&cache, 0);
+ ++ci;
+ }
}
return 0;
// Cache data is written out when the JigdoCache is destroyed
the image to complete it. Reads info from tmp file or (if
imageTmpFile.empty() or error opening tmp file) outputs complete
list from template. */
- static int listMissing(set<MD5>& result, const string& imageTmpFile,
+ static int listMissingMD5(set<MD5>& result, const string& imageTmpFile,
+ const string& templFile, bistream* templ, ProgressReporter& reporter);
+ /** Return list of SHA256sums of files that still need to be copied to
+ the image to complete it. Reads info from tmp file or (if
+ imageTmpFile.empty() or error opening tmp file) outputs complete
+ list from template. */
+ static int listMissingSHA256(set<SHA256>& result, const string& imageTmpFile,
const string& templFile, bistream* templ, ProgressReporter& reporter);
class ImageInfoMD5;