mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-25 22:46:04 +03:00
Sync: optimize by removing setFileRecordMetadata
Inh most case we already have a record from before, so avoid doing a useless lookup in the database. In owncloudpropagator.cpp, directories do not have a checksum so no need to call a function that preserves it
This commit is contained in:
parent
416a0b3482
commit
69de2d5180
6 changed files with 8 additions and 35 deletions
|
@ -1297,31 +1297,6 @@ bool SyncJournalDb::updateLocalMetadata(const QString &filename,
|
|||
return _setFileRecordLocalMetadataQuery.exec();
|
||||
}
|
||||
|
||||
bool SyncJournalDb::setFileRecordMetadata(const SyncJournalFileRecord &record)
|
||||
{
|
||||
SyncJournalFileRecord existing;
|
||||
if (!getFileRecord(record._path, &existing))
|
||||
return false;
|
||||
|
||||
// If there's no existing record, just insert the new one.
|
||||
if (!existing.isValid()) {
|
||||
return setFileRecord(record);
|
||||
}
|
||||
|
||||
// Update the metadata on the existing record.
|
||||
existing._inode = record._inode;
|
||||
existing._modtime = record._modtime;
|
||||
existing._type = record._type;
|
||||
existing._etag = record._etag;
|
||||
existing._fileId = record._fileId;
|
||||
existing._remotePerm = record._remotePerm;
|
||||
existing._fileSize = record._fileSize;
|
||||
existing._serverHasIgnoredFiles = record._serverHasIgnoredFiles;
|
||||
existing._e2eMangledName = record._e2eMangledName;
|
||||
existing._isE2eEncrypted = record._isE2eEncrypted;
|
||||
return setFileRecord(existing);
|
||||
}
|
||||
|
||||
static void toDownloadInfo(SqlQuery &query, SyncJournalDb::DownloadInfo *res)
|
||||
{
|
||||
bool ok = true;
|
||||
|
|
|
@ -64,9 +64,6 @@ public:
|
|||
bool listFilesInPath(const QByteArray &path, const std::function<void(const SyncJournalFileRecord&)> &rowCallback);
|
||||
bool setFileRecord(const SyncJournalFileRecord &record);
|
||||
|
||||
/// Like setFileRecord, but preserves checksums
|
||||
bool setFileRecordMetadata(const SyncJournalFileRecord &record);
|
||||
|
||||
bool deleteFileRecord(const QString &filename, bool recursively = false);
|
||||
bool updateFileRecordChecksum(const QString &filename,
|
||||
const QByteArray &contentChecksum,
|
||||
|
|
|
@ -884,7 +884,7 @@ void ProcessDirectoryJob::processFileConflict(const SyncFileItemPtr &item, Proce
|
|||
rec._fileSize = serverEntry.size;
|
||||
rec._remotePerm = serverEntry.remotePerm;
|
||||
rec._checksumHeader = serverEntry.checksumHeader;
|
||||
_discoveryData->_statedb->setFileRecordMetadata(rec);
|
||||
_discoveryData->_statedb->setFileRecord(rec);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -967,7 +967,7 @@ void PropagateDirectory::slotSubJobsFinished(SyncFileItem::Status status)
|
|||
}
|
||||
}
|
||||
SyncJournalFileRecord record = _item->toSyncJournalFileRecordWithInode(propagator()->_localDir + _item->_file);
|
||||
bool ok = propagator()->_journal->setFileRecordMetadata(record);
|
||||
bool ok = propagator()->_journal->setFileRecord(record);
|
||||
if (!ok) {
|
||||
status = _item->_status = SyncFileItem::FatalError;
|
||||
_item->_errorString = tr("Error writing metadata to the database");
|
||||
|
|
|
@ -326,15 +326,16 @@ void OCC::SyncEngine::slotItemDiscovered(const OCC::SyncFileItemPtr &item)
|
|||
const bool isReadOnly = !item->_remotePerm.isNull() && !item->_remotePerm.hasPermission(RemotePermissions::CanWrite);
|
||||
FileSystem::setFileReadOnlyWeak(filePath, isReadOnly);
|
||||
}
|
||||
|
||||
_journal->setFileRecordMetadata(item->toSyncJournalFileRecordWithInode(filePath));
|
||||
auto rec = item->toSyncJournalFileRecordWithInode(filePath);
|
||||
if (rec._checksumHeader.isEmpty())
|
||||
rec._checksumHeader = prev._checksumHeader;
|
||||
rec._serverHasIgnoredFiles |= prev._serverHasIgnoredFiles;
|
||||
_journal->setFileRecord(rec);
|
||||
|
||||
// This might have changed the shared flag, so we must notify SyncFileStatusTracker for example
|
||||
emit itemCompleted(item);
|
||||
} else {
|
||||
// The local tree is walked first and doesn't have all the info from the server.
|
||||
// Update only outdated data from the disk.
|
||||
// FIXME! I think this is no longer the case so a setFileRecordMetadata should work
|
||||
_journal->updateLocalMetadata(item->_file, item->_modtime, item->_size, item->_inode);
|
||||
}
|
||||
_hasNoneFiles = true;
|
||||
|
|
|
@ -81,7 +81,7 @@ private slots:
|
|||
record._fileId = "efg";
|
||||
record._remotePerm = RemotePermissions::fromDbValue("NV");
|
||||
record._fileSize = 289055;
|
||||
_db.setFileRecordMetadata(record);
|
||||
_db.setFileRecord(record);
|
||||
QVERIFY(_db.getFileRecord(QByteArrayLiteral("foo"), &storedRecord));
|
||||
QVERIFY(storedRecord == record);
|
||||
|
||||
|
|
Loading…
Reference in a new issue