"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/libsync/discovery.cpp" between
ownCloud-2.9.0.5150.tar.xz and ownCloud-2.9.1.5500.tar.xz

About: ownCloud Client (formerly "mirall") is a tool to synchronize files from ownCloud Server with your desktop client. It uses OCSync as its syncing backend.

discovery.cpp  (ownCloud-2.9.0.5150.tar.xz):discovery.cpp  (ownCloud-2.9.1.5500.tar.xz)
skipping to change at line 93 skipping to change at line 93
std::map<QString, Entries> entries; std::map<QString, Entries> entries;
for (auto &e : _serverNormalQueryEntries) { for (auto &e : _serverNormalQueryEntries) {
entries[e.name].serverEntry = std::move(e); entries[e.name].serverEntry = std::move(e);
} }
_serverNormalQueryEntries.clear(); _serverNormalQueryEntries.clear();
// fetch all the name from the DB // fetch all the name from the DB
auto pathU8 = _currentFolder._original.toUtf8(); auto pathU8 = _currentFolder._original.toUtf8();
if (!_discoveryData->_statedb->listFilesInPath(pathU8, [&](const SyncJournal FileRecord &rec) { if (!_discoveryData->_statedb->listFilesInPath(pathU8, [&](const SyncJournal FileRecord &rec) {
auto name = pathU8.isEmpty() ? QString::fromUtf8(rec._path) : QStrin g::fromUtf8(rec._path.constData() + (pathU8.size() + 1)); auto name = pathU8.isEmpty() ? QString::fromUtf8(rec._path) : QStrin g::fromUtf8(rec._path.constData() + (pathU8.size() + 1));
if (rec.isVirtualFile() && isVfsWithSuffix()) if (rec.isVirtualFile() && isVfsWithSuffix()) {
chopVirtualFileSuffix(name); name = chopVirtualFileSuffix(name);
}
auto &dbEntry = entries[name].dbEntry; auto &dbEntry = entries[name].dbEntry;
dbEntry = rec; dbEntry = rec;
setupDbPinStateActions(dbEntry); setupDbPinStateActions(dbEntry);
})) { })) {
dbError(); dbError();
return; return;
} }
for (auto &e : _localNormalQueryEntries) { for (auto &e : _localNormalQueryEntries) {
entries[e.name].localEntry = e; entries[e.name].localEntry = e;
skipping to change at line 118 skipping to change at line 119
// with the non-suffixed name. Unless both names exist locally or there' s // with the non-suffixed name. Unless both names exist locally or there' s
// other data about the suffixed file. // other data about the suffixed file.
// This is done in a second path in order to not depend on the order of // This is done in a second path in order to not depend on the order of
// _localNormalQueryEntries. // _localNormalQueryEntries.
for (auto &e : _localNormalQueryEntries) { for (auto &e : _localNormalQueryEntries) {
if (!e.isVirtualFile) if (!e.isVirtualFile)
continue; continue;
auto &suffixedEntry = entries[e.name]; auto &suffixedEntry = entries[e.name];
bool hasOtherData = suffixedEntry.serverEntry.isValid() || suffixedE ntry.dbEntry.isValid(); bool hasOtherData = suffixedEntry.serverEntry.isValid() || suffixedE ntry.dbEntry.isValid();
auto nonvirtualName = e.name; auto nonvirtualName = chopVirtualFileSuffix(e.name);
chopVirtualFileSuffix(nonvirtualName);
auto &nonvirtualEntry = entries[nonvirtualName]; auto &nonvirtualEntry = entries[nonvirtualName];
// If the non-suffixed entry has no data, move it // If the non-suffixed entry has no data, move it
if (!nonvirtualEntry.localEntry.isValid()) { if (!nonvirtualEntry.localEntry.isValid()) {
std::swap(nonvirtualEntry.localEntry, suffixedEntry.localEntry); std::swap(nonvirtualEntry.localEntry, suffixedEntry.localEntry);
if (!hasOtherData) if (!hasOtherData)
entries.erase(e.name); entries.erase(e.name);
} else if (!hasOtherData) { } else if (!hasOtherData) {
// Normally a lone local suffixed file would be processed under the // Normally a lone local suffixed file would be processed under the
// unsuffixed name. In this special case it's under the suffixed name. // unsuffixed name. In this special case it's under the suffixed name.
// To avoid lots of special casing, make sure PathTuple::addName () // To avoid lots of special casing, make sure PathTuple::addName ()
skipping to change at line 989 skipping to change at line 989
qCInfo(lcDisco) << "Rename detected (up) " << item->_file << " -> " << i tem->_renameTarget; qCInfo(lcDisco) << "Rename detected (up) " << item->_file << " -> " << i tem->_renameTarget;
}; };
if (wasDeletedOnClient.first) { if (wasDeletedOnClient.first) {
recurseQueryServer = wasDeletedOnClient.second == base._etag ? ParentNot Changed : NormalQuery; recurseQueryServer = wasDeletedOnClient.second == base._etag ? ParentNot Changed : NormalQuery;
processRename(path); processRename(path);
} else { } else {
// We must query the server to know if the etag has not changed // We must query the server to know if the etag has not changed
_pendingAsyncJobs++; _pendingAsyncJobs++;
QString serverOriginalPath = _discoveryData->_remoteFolder + _discoveryD ata->adjustRenamedPath(originalPath, SyncFileItem::Down); QString serverOriginalPath = _discoveryData->_remoteFolder + _discoveryD ata->adjustRenamedPath(originalPath, SyncFileItem::Down);
if (base.isVirtualFile() && isVfsWithSuffix()) if (base.isVirtualFile() && isVfsWithSuffix()) {
chopVirtualFileSuffix(serverOriginalPath); serverOriginalPath = chopVirtualFileSuffix(serverOriginalPath);
}
auto job = new RequestEtagJob(_discoveryData->_account, serverOriginalPa th, this); auto job = new RequestEtagJob(_discoveryData->_account, serverOriginalPa th, this);
connect(job, &RequestEtagJob::finishedWithResult, this, [=](const HttpRe sult<QByteArray> &etag) mutable { connect(job, &RequestEtagJob::finishedWithResult, this, [=](const HttpRe sult<QByteArray> &etag) mutable {
if (!etag || (etag.get() != base._etag && !item->isDirectory()) || _ discoveryData->isRenamed(originalPath)) { if (!etag || (etag.get() != base._etag && !item->isDirectory()) || _ discoveryData->isRenamed(originalPath)) {
qCInfo(lcDisco) << "Can't rename because the etag has changed or the directory is gone" << originalPath; qCInfo(lcDisco) << "Can't rename because the etag has changed or the directory is gone" << originalPath;
// Can't be a rename, leave it as a new. // Can't be a rename, leave it as a new.
postProcessLocalNew(); postProcessLocalNew();
} else { } else {
// In case the deleted item was discovered in parallel // In case the deleted item was discovered in parallel
_discoveryData->findAndCancelDeletedJob(originalPath); _discoveryData->findAndCancelDeletedJob(originalPath);
processRename(path); processRename(path);
skipping to change at line 1369 skipping to change at line 1370
str.append(_discoveryData->_syncOptions._vfs->fileSuffix()); str.append(_discoveryData->_syncOptions._vfs->fileSuffix());
} }
bool ProcessDirectoryJob::hasVirtualFileSuffix(const QString &str) const bool ProcessDirectoryJob::hasVirtualFileSuffix(const QString &str) const
{ {
if (!isVfsWithSuffix()) if (!isVfsWithSuffix())
return false; return false;
return str.endsWith(_discoveryData->_syncOptions._vfs->fileSuffix()); return str.endsWith(_discoveryData->_syncOptions._vfs->fileSuffix());
} }
void ProcessDirectoryJob::chopVirtualFileSuffix(QString &str) const QString ProcessDirectoryJob::chopVirtualFileSuffix(const QString &str) const
{ {
if (!isVfsWithSuffix()) if (!isVfsWithSuffix())
return; return str;
bool hasSuffix = hasVirtualFileSuffix(str); // ensure we do it only with virtual files in this class
OC_ASSERT(hasSuffix); Q_ASSERT(hasVirtualFileSuffix(str));
if (hasSuffix) return _discoveryData->_syncOptions._vfs->underlyingFileName(str);
str.chop(_discoveryData->_syncOptions._vfs->fileSuffix().size());
} }
DiscoverySingleDirectoryJob *ProcessDirectoryJob::startAsyncServerQuery() DiscoverySingleDirectoryJob *ProcessDirectoryJob::startAsyncServerQuery()
{ {
auto serverJob = new DiscoverySingleDirectoryJob(_discoveryData->_account, auto serverJob = new DiscoverySingleDirectoryJob(_discoveryData->_account,
_discoveryData->_remoteFolder + _currentFolder._server, this); _discoveryData->_remoteFolder + _currentFolder._server, this);
if (!_dirItem) if (!_dirItem)
serverJob->setIsRootPath(); // query the fingerprint on the root serverJob->setIsRootPath(); // query the fingerprint on the root
connect(serverJob, &DiscoverySingleDirectoryJob::etag, this, &ProcessDirecto ryJob::etag); connect(serverJob, &DiscoverySingleDirectoryJob::etag, this, &ProcessDirecto ryJob::etag);
_discoveryData->_currentlyActiveJobs++; _discoveryData->_currentlyActiveJobs++;
 End of changes. 5 change blocks. 
12 lines changed or deleted 12 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)