void PropagateRemoteMove::finalize() { SyncJournalFileRecord oldRecord; propagator()->_journal->getFileRecord(_item->_originalFile, &oldRecord); // if reading from db failed still continue hoping that deleteFileRecord // reopens the db successfully. // The db is only queried to transfer the content checksum from the old // to the new record. It is not a problem to skip it here. propagator()->_journal->deleteFileRecord(_item->_originalFile); SyncFileItem newItem(*_item); newItem._type = _item->_type; if (oldRecord.isValid()) { newItem._checksumHeader = oldRecord._checksumHeader; if (newItem._size != oldRecord._fileSize) { qCWarning(lcPropagateRemoteMove) << "File sizes differ on server vs sync journal: " << newItem._size << oldRecord._fileSize; // the server might have claimed a different size, we take the old one from the DB newItem._size = oldRecord._fileSize; } } if (!propagator()->updateMetadata(newItem)) { done(SyncFileItem::FatalError, tr("Error writing metadata to the database")); return; } if (_item->isDirectory()) { propagator()->_renamedDirectories.insert(_item->_file, _item->_renameTarget); if (!adjustSelectiveSync(propagator()->_journal, _item->_file, _item->_renameTarget)) { done(SyncFileItem::FatalError, tr("Error writing metadata to the database")); return; } } propagator()->_journal->commit("Remote Rename"); done(SyncFileItem::Success); }
void PropagateRemoteMove::finalize() { SyncJournalFileRecord oldRecord = _propagator->_journal->getFileRecord(_item->_originalFile); // if reading from db failed still continue hoping that deleteFileRecord // reopens the db successfully. // The db is only queried to transfer the content checksum from the old // to the new record. It is not a problem to skip it here. _propagator->_journal->deleteFileRecord(_item->_originalFile); SyncJournalFileRecord record(*_item, _propagator->getFilePath(_item->_renameTarget)); record._path = _item->_renameTarget; if (oldRecord.isValid()) { record._contentChecksum = oldRecord._contentChecksum; record._contentChecksumType = oldRecord._contentChecksumType; if (record._fileSize != oldRecord._fileSize) { qDebug() << "Warning: file sizes differ on server vs csync_journal: " << record._fileSize << oldRecord._fileSize; record._fileSize = oldRecord._fileSize; // server might have claimed different size, we take the old one from the DB } } if (!_propagator->_journal->setFileRecord(record)) { done(SyncFileItem::FatalError, tr("Error writing metadata to the database")); return; } if (_item->_isDirectory) { if (!adjustSelectiveSync(_propagator->_journal, _item->_file, _item->_renameTarget)) { done(SyncFileItem::FatalError, tr("Error writing metadata to the database")); return; } } _propagator->_journal->commit("Remote Rename"); done(SyncFileItem::Success); }