mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-24 21:35:47 +03:00
Merge pull request #4656 from owncloud/close_journal_fix
Close journal fix - do not keep the journal open or reopen on error.
This commit is contained in:
commit
6cb94e8849
6 changed files with 35 additions and 16 deletions
|
@ -762,12 +762,14 @@ void CleanupPollsJob::start()
|
||||||
|
|
||||||
auto info = _pollInfos.first();
|
auto info = _pollInfos.first();
|
||||||
_pollInfos.pop_front();
|
_pollInfos.pop_front();
|
||||||
SyncFileItemPtr item(new SyncFileItem(
|
SyncJournalFileRecord record = _journal->getFileRecord(info._file);
|
||||||
_journal->getFileRecord(info._file).toSyncFileItem()));
|
SyncFileItemPtr item(new SyncFileItem(record.toSyncFileItem()));
|
||||||
|
if (record.isValid()) {
|
||||||
PollJob *job = new PollJob(_account, info._url, item, _journal, _localPath, this);
|
PollJob *job = new PollJob(_account, info._url, item, _journal, _localPath, this);
|
||||||
connect(job, SIGNAL(finishedSignal()), SLOT(slotPollFinished()));
|
connect(job, SIGNAL(finishedSignal()), SLOT(slotPollFinished()));
|
||||||
job->start();
|
job->start();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CleanupPollsJob::slotPollFinished()
|
void CleanupPollsJob::slotPollFinished()
|
||||||
{
|
{
|
||||||
|
|
|
@ -154,16 +154,22 @@ void PropagateRemoteMove::finalize()
|
||||||
{
|
{
|
||||||
SyncJournalFileRecord oldRecord =
|
SyncJournalFileRecord oldRecord =
|
||||||
_propagator->_journal->getFileRecord(_item->_originalFile);
|
_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);
|
_propagator->_journal->deleteFileRecord(_item->_originalFile);
|
||||||
|
|
||||||
SyncJournalFileRecord record(*_item, _propagator->getFilePath(_item->_renameTarget));
|
SyncJournalFileRecord record(*_item, _propagator->getFilePath(_item->_renameTarget));
|
||||||
record._path = _item->_renameTarget;
|
record._path = _item->_renameTarget;
|
||||||
|
if (oldRecord.isValid()) {
|
||||||
record._contentChecksum = oldRecord._contentChecksum;
|
record._contentChecksum = oldRecord._contentChecksum;
|
||||||
record._contentChecksumType = oldRecord._contentChecksumType;
|
record._contentChecksumType = oldRecord._contentChecksumType;
|
||||||
if (record._fileSize != oldRecord._fileSize) {
|
if (record._fileSize != oldRecord._fileSize) {
|
||||||
qDebug() << "Warning: file sizes differ on server vs csync_journal: " << 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
|
record._fileSize = oldRecord._fileSize; // server might have claimed different size, we take the old one from the DB
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!_propagator->_journal->setFileRecord(record)) {
|
if (!_propagator->_journal->setFileRecord(record)) {
|
||||||
done(SyncFileItem::FatalError, tr("Error writing metadata to the database"));
|
done(SyncFileItem::FatalError, tr("Error writing metadata to the database"));
|
||||||
|
|
|
@ -235,8 +235,10 @@ void PropagateLocalRename::start()
|
||||||
|
|
||||||
SyncJournalFileRecord record(*_item, targetFile);
|
SyncJournalFileRecord record(*_item, targetFile);
|
||||||
record._path = _item->_renameTarget;
|
record._path = _item->_renameTarget;
|
||||||
|
if (oldRecord.isValid()) {
|
||||||
record._contentChecksum = oldRecord._contentChecksum;
|
record._contentChecksum = oldRecord._contentChecksum;
|
||||||
record._contentChecksumType = oldRecord._contentChecksumType;
|
record._contentChecksumType = oldRecord._contentChecksumType;
|
||||||
|
}
|
||||||
|
|
||||||
if (!_item->_isDirectory) { // Directories are saved at the end
|
if (!_item->_isDirectory) { // Directories are saved at the end
|
||||||
if (!_propagator->_journal->setFileRecord(record)) {
|
if (!_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
|
// If the 'W' remote permission changed, update the local filesystem
|
||||||
SyncJournalFileRecord prev = _journal->getFileRecord(item->_file);
|
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');
|
const bool isReadOnly = !item->_remotePerm.contains('W');
|
||||||
FileSystem::setFileReadOnlyWeak(filePath, isReadOnly);
|
FileSystem::setFileReadOnlyWeak(filePath, isReadOnly);
|
||||||
}
|
}
|
||||||
|
@ -1018,6 +1018,7 @@ void SyncEngine::finalize(bool success)
|
||||||
_thread.wait();
|
_thread.wait();
|
||||||
|
|
||||||
csync_commit(_csync_ctx);
|
csync_commit(_csync_ctx);
|
||||||
|
_journal->close();
|
||||||
|
|
||||||
qDebug() << "CSync run took " << _stopWatch.addLapTime(QLatin1String("Sync Finished"));
|
qDebug() << "CSync run took " << _stopWatch.addLapTime(QLatin1String("Sync Finished"));
|
||||||
_stopWatch.stop();
|
_stopWatch.stop();
|
||||||
|
|
|
@ -784,6 +784,8 @@ SyncJournalFileRecord SyncJournalDb::getFileRecord( const QString& filename )
|
||||||
if (!_getFileRecordQuery->exec()) {
|
if (!_getFileRecordQuery->exec()) {
|
||||||
QString err = _getFileRecordQuery->error();
|
QString err = _getFileRecordQuery->error();
|
||||||
qDebug() << "Error creating prepared statement: " << _getFileRecordQuery->lastQuery() << ", Error:" << err;;
|
qDebug() << "Error creating prepared statement: " << _getFileRecordQuery->lastQuery() << ", Error:" << err;;
|
||||||
|
locker.unlock();
|
||||||
|
close();
|
||||||
return rec;
|
return rec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -806,7 +808,10 @@ SyncJournalFileRecord SyncJournalDb::getFileRecord( const QString& filename )
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
QString err = _getFileRecordQuery->error();
|
QString err = _getFileRecordQuery->error();
|
||||||
qDebug() << "No journal entry found for " << filename;
|
qDebug() << "No journal entry found for " << filename << "Error: " << err;
|
||||||
|
locker.unlock();
|
||||||
|
close();
|
||||||
|
locker.relock();
|
||||||
}
|
}
|
||||||
_getFileRecordQuery->reset_and_clear_bindings();
|
_getFileRecordQuery->reset_and_clear_bindings();
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,9 @@ class OWNCLOUDSYNC_EXPORT SyncJournalDb : public QObject
|
||||||
public:
|
public:
|
||||||
explicit SyncJournalDb(const QString& path, QObject *parent = 0);
|
explicit SyncJournalDb(const QString& path, QObject *parent = 0);
|
||||||
virtual ~SyncJournalDb();
|
virtual ~SyncJournalDb();
|
||||||
|
|
||||||
|
// to verify that the record could be queried successfully check
|
||||||
|
// with SyncJournalFileRecord::isValid()
|
||||||
SyncJournalFileRecord getFileRecord(const QString& filename);
|
SyncJournalFileRecord getFileRecord(const QString& filename);
|
||||||
bool setFileRecord( const SyncJournalFileRecord& record );
|
bool setFileRecord( const SyncJournalFileRecord& record );
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue