Skip to content

Commit d73b218

Browse files
author
Uwe Runtemund
committed
Improved cliend side sync process for tags. Some code clean-up.
1 parent c8c81b3 commit d73b218

13 files changed

+602
-542
lines changed

src/common/syncjournaldb.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,7 +1506,7 @@ bool SyncJournalDb::updateMetadataTagList(const QString &filename,const QByteArr
15061506
{
15071507
QMutexLocker locker(&_mutex);
15081508

1509-
qCInfo(lcDb) << "Updating file tag lists " << filename;
1509+
qCInfo(lcDb) << "Updating file tag list " << filename;
15101510

15111511
if (!checkConnect()) {
15121512
qCWarning(lcDb) << "Failed to connect database.";
@@ -1525,7 +1525,6 @@ bool SyncJournalDb::updateMetadataTagList(const QString &filename,const QByteArr
15251525
}
15261526
query->bindValue(1, phash);
15271527
query->bindValue(2, *tagList);
1528-
printf("RMD UPDATE TAG\n");
15291528
return query->exec();
15301529
}
15311530

@@ -1552,7 +1551,6 @@ QByteArray SyncJournalDb::tagList(const QString &file)
15521551
if (!next.ok || !next.hasData)return QByteArray();
15531552

15541553
QByteArray result = query->baValue(0);
1555-
printf("RMD YES %lld %s!\n",phash,result.data());
15561554
return result;
15571555
}
15581556

src/gui/folder.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,6 @@ void Folder::slotWatchedPathChanged(const QString &path, ChangeReason reason)
558558
qCDebug(lcFolder) << "Changed path is not contained in folder, ignoring:" << path;
559559
return;
560560
}
561-
printf("RMD Change 2\n");
562561
auto relativePath = path.midRef(this->path().size());
563562

564563
if (pathIsIgnored(path)) {
@@ -628,7 +627,6 @@ void Folder::slotWatchedPathChanged(const QString &path, ChangeReason reason)
628627
}
629628
}
630629
warnOnNewExcludedItem(record, relativePath);
631-
printf("RMD Change 3\n");
632630
emit watchedFileChangedExternally(path);
633631

634632
// Also schedule this folder for a sync, but only after some delay:

src/gui/folderwatcher.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,6 @@ void FolderWatcher::changeDetected(const QStringList &paths)
263263

264264
qCInfo(lcFolderWatcher) << "Detected changes in paths:" << changedPaths;
265265
for (const auto &path : changedPaths) {
266-
printf("RMD Change 1\n");
267266
emit pathChanged(path);
268267
}
269268
}

src/libsync/discovery.cpp

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -495,20 +495,15 @@ void ProcessDirectoryJob::processFile(PathTuple path,
495495

496496
if(localEntry.isValid()
497497
&& dbEntry.isValid()) {
498-
FileTagManager* tm = FileTagManager::GetInstance();
499498

500-
// Try tag pull by default (order pull,push is relevant!)
501-
tm->pullTags(_discoveryData->_localDir % path._original,
502-
localEntry,
503-
dbEntry);
504-
505-
// Only if all three entries are valid, we make a full sync.
506-
if(serverEntry.isValid()) {
507-
tm->pushTags(_discoveryData->_localDir % path._original,
508-
localEntry,
509-
serverEntry,
510-
dbEntry);
511-
}
499+
// Tag synchronization
500+
FileTagManager::syncTags(_discoveryData->_account,
501+
_discoveryData->_statedb,
502+
_discoveryData->_localDir,
503+
path._original,
504+
localEntry,
505+
serverEntry,
506+
dbEntry);
512507
}
513508

514509
if (_discoveryData->isRenamed(path._original)) {

src/libsync/discoveryphase.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,8 @@ void DiscoverySingleDirectoryJob::start()
395395
<< "http://owncloud.org/ns:permissions"
396396
<< "http://owncloud.org/ns:checksums"
397397
<< "http://owncloud.org/ns:tags"
398-
<< "http://nextcloud.org/ns:system-tags";
398+
<< "http://nextcloud.org/ns:system-tags"
399+
<< "http://nextcloud.org/ns:metadata_etag";
399400

400401
if (_isRootPath)
401402
props << "http://owncloud.org/ns:data-fingerprint";
@@ -543,11 +544,10 @@ static void propertyMapToRemoteInfo(const QMap<QString, QString> &map, RemoteInf
543544
}
544545
}
545546
if(property == "system-tags" || property == "tags"){
546-
QByteArray list =FileTagManager::fromPropertiesToTagList(value);
547-
if(list.size()>0){
548-
if(result.tagList.size()>0)result.tagList.append('\n');
549-
result.tagList.append(list);
550-
}
547+
FileTagManager::fromPropertiesToTagList(result.tagList,value);
548+
}
549+
if(property == "metadata_etag"){
550+
//TODO: RMD Handle metadata etag for tag synchronization
551551
}
552552
}
553553

src/libsync/filesystem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ bool FileSystem::fileChanged(const QString &fileName,
9191
{
9292
return getSize(fileName) != previousSize
9393
|| getModTime(fileName) != previousMtime
94-
|| FileTagManager::GetInstance()->readTagListFromLocalFile(fileName) != taglist;
94+
|| FileTagManager::readTagListFromLocalFile(fileName) != taglist;
9595
}
9696

9797
bool FileSystem::verifyFileUnchanged(const QString &fileName,

0 commit comments

Comments
 (0)