mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-24 13:25:52 +03:00
Check if the record returned from getFileRecord is valid.
Handle database fails properly.
This commit is contained in:
parent
648328fbe2
commit
d433c24186
4 changed files with 23 additions and 13 deletions
|
@ -754,11 +754,13 @@ void CleanupPollsJob::start()
|
|||
|
||||
auto info = _pollInfos.first();
|
||||
_pollInfos.pop_front();
|
||||
SyncFileItemPtr item(new SyncFileItem(
|
||||
_journal->getFileRecord(info._file).toSyncFileItem()));
|
||||
PollJob *job = new PollJob(_account, info._url, item, _journal, _localPath, this);
|
||||
connect(job, SIGNAL(finishedSignal()), SLOT(slotPollFinished()));
|
||||
job->start();
|
||||
SyncJournalFileRecord record = _journal->getFileRecord(info._file);
|
||||
SyncFileItemPtr item(new SyncFileItem(record.toSyncFileItem()));
|
||||
if (record.isValid()) {
|
||||
PollJob *job = new PollJob(_account, info._url, item, _journal, _localPath, this);
|
||||
connect(job, SIGNAL(finishedSignal()), SLOT(slotPollFinished()));
|
||||
job->start();
|
||||
}
|
||||
}
|
||||
|
||||
void CleanupPollsJob::slotPollFinished()
|
||||
|
|
|
@ -154,15 +154,21 @@ 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;
|
||||
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 (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
|
||||
}
|
||||
}
|
||||
|
||||
_propagator->_journal->setFileRecord(record);
|
||||
|
|
|
@ -232,8 +232,10 @@ void PropagateLocalRename::start()
|
|||
|
||||
SyncJournalFileRecord record(*_item, targetFile);
|
||||
record._path = _item->_renameTarget;
|
||||
record._contentChecksum = oldRecord._contentChecksum;
|
||||
record._contentChecksumType = oldRecord._contentChecksumType;
|
||||
if (oldRecord.isValid()) {
|
||||
record._contentChecksum = oldRecord._contentChecksum;
|
||||
record._contentChecksumType = oldRecord._contentChecksumType;
|
||||
}
|
||||
|
||||
if (!_item->_isDirectory) { // Directories are saved at the end
|
||||
_propagator->_journal->setFileRecord(record);
|
||||
|
|
|
@ -519,7 +519,7 @@ int SyncEngine::treewalkFile( TREE_WALK_FILE *file, bool remote )
|
|||
|
||||
// If the 'W' remote permission changed, update the local filesystem
|
||||
SyncJournalFileRecord prev = _journal->getFileRecord(item->_file);
|
||||
if (prev._remotePerm.contains('W') != item->_remotePerm.contains('W')) {
|
||||
if (prev.isValid() && prev._remotePerm.contains('W') != item->_remotePerm.contains('W')) {
|
||||
const bool isReadOnly = !item->_remotePerm.contains('W');
|
||||
FileSystem::setFileReadOnlyWeak(filePath, isReadOnly);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue