item->_instruction = instruction;
item->_modtime = file->modtime;
item->_size = file->size;
+ item->_checksumHeader = file->checksumHeader;
} else {
if (instruction != CSYNC_INSTRUCTION_NONE) {
qCWarning(lcEngine) << "ERROR: Instruction" << item->_instruction << "vs" << instruction << "for" << fileUtf8;
item->_serverHasIgnoredFiles = file->has_ignored_files;
}
- // Sometimes the discovery computes checksums for local files
- if (!remote && !file->checksumHeader.isEmpty()) {
- item->_checksumHeader = file->checksumHeader;
- }
- // For conflicts, store the remote checksum there
- if (remote && item->_instruction == CSYNC_INSTRUCTION_CONFLICT && !file->checksumHeader.isEmpty()) {
- item->_checksumHeader = file->checksumHeader;
- }
-
// record the seen files to be able to clean the journal later
_seenFiles.insert(item->_file);
if (!renameTarget.isEmpty()) {
QByteArray _fileId;
QByteArray _remotePerm;
+ // This is the value for the 'new' side, matching with _size and _modtime.
+ //
// When is this set, and is it the local or the remote checksum?
// - if mtime or size changed locally for *.eml files (local checksum)
// - for potential renames of local files (local checksum)
- // - for conflicts (remote checksum) (what about eval_rename/new reconcile?)
+ // - for conflicts (remote checksum)
QByteArray _checksumHeader;
// The size and modtime of the file getting overwritten (on the disk for downloads, on the server for uploads).
fakeFolder.localModifier().insert("a1.eml", 64, 'A');
fakeFolder.localModifier().insert("a2.eml", 64, 'A');
fakeFolder.localModifier().insert("a3.eml", 64, 'A');
+ fakeFolder.localModifier().insert("b3.txt", 64, 'A');
// Upload and calculate the checksums
// fakeFolder.syncOnce();
fakeFolder.syncOnce();
+ auto getDbChecksum = [&](QString path) {
+ auto record = fakeFolder.syncJournal().getFileRecord(path);
+ return record._checksumHeader;
+ };
+
+ // printf 'A%.0s' {1..64} | sha1sum -
+ QByteArray referenceChecksum("SHA1:30b86e44e6001403827a62c58b08893e77cf121f");
+ QCOMPARE(getDbChecksum("a1.eml"), referenceChecksum);
+ QCOMPARE(getDbChecksum("a2.eml"), referenceChecksum);
+ QCOMPARE(getDbChecksum("a3.eml"), referenceChecksum);
+ QCOMPARE(getDbChecksum("b3.txt"), referenceChecksum);
+
QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItemPtr &)));
// Touch the file without changing the content, shouldn't upload
fakeFolder.localModifier().setContents("a1.eml", 'A');
// Change the content/size
fakeFolder.localModifier().setContents("a2.eml", 'B');
fakeFolder.localModifier().appendByte("a3.eml");
+ fakeFolder.localModifier().appendByte("b3.txt");
fakeFolder.syncOnce();
+ QCOMPARE(getDbChecksum("a1.eml"), referenceChecksum);
+ QCOMPARE(getDbChecksum("a2.eml"), QByteArray("SHA1:84951fc23a4dafd10020ac349da1f5530fa65949"));
+ QCOMPARE(getDbChecksum("a3.eml"), QByteArray("SHA1:826b7e7a7af8a529ae1c7443c23bf185c0ad440c"));
+ QCOMPARE(getDbChecksum("b3.eml"), getDbChecksum("a3.txt"));
+
QVERIFY(!itemDidComplete(completeSpy, "a1.eml"));
QVERIFY(itemDidCompleteSuccessfully(completeSpy, "a2.eml"));
QVERIFY(itemDidCompleteSuccessfully(completeSpy, "a3.eml"));