Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHannah von Reth <hannah.vonreth@owncloud.com>2021-09-17 15:50:23 +0300
committerHannah von Reth <vonreth@kde.org>2021-09-21 11:30:03 +0300
commit08985e7d73733a4c70e7e66850adcf7f1fd33f36 (patch)
tree8d94bbbc70d0608f159c355f5c2ddc31be62ae7f /src/libsync
parent15dbff6635ad25aed6f56848131e3b68b04f0778 (diff)
Don't ignore suffix placeholder
Diffstat (limited to 'src/libsync')
-rw-r--r--src/libsync/discovery.cpp24
-rw-r--r--src/libsync/discovery.h2
-rw-r--r--src/libsync/syncfilestatustracker.cpp2
-rw-r--r--src/libsync/vfs/suffix/vfs_suffix.cpp17
-rw-r--r--src/libsync/vfs/suffix/vfs_suffix.h2
5 files changed, 28 insertions, 19 deletions
diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp
index e8f1d2a2a..fac99ccf4 100644
--- a/src/libsync/discovery.cpp
+++ b/src/libsync/discovery.cpp
@@ -90,8 +90,9 @@ void ProcessDirectoryJob::process()
auto pathU8 = _currentFolder._original.toUtf8();
if (!_discoveryData->_statedb->listFilesInPath(pathU8, [&](const SyncJournalFileRecord &rec) {
auto name = pathU8.isEmpty() ? QString::fromUtf8(rec._path) : QString::fromUtf8(rec._path.constData() + (pathU8.size() + 1));
- if (rec.isVirtualFile() && isVfsWithSuffix())
- chopVirtualFileSuffix(name);
+ if (rec.isVirtualFile() && isVfsWithSuffix()) {
+ name = chopVirtualFileSuffix(name);
+ }
auto &dbEntry = entries[name].dbEntry;
dbEntry = rec;
setupDbPinStateActions(dbEntry);
@@ -115,8 +116,7 @@ void ProcessDirectoryJob::process()
auto &suffixedEntry = entries[e.name];
bool hasOtherData = suffixedEntry.serverEntry.isValid() || suffixedEntry.dbEntry.isValid();
- auto nonvirtualName = e.name;
- chopVirtualFileSuffix(nonvirtualName);
+ auto nonvirtualName = chopVirtualFileSuffix(e.name);
auto &nonvirtualEntry = entries[nonvirtualName];
// If the non-suffixed entry has no data, move it
if (!nonvirtualEntry.localEntry.isValid()) {
@@ -986,8 +986,9 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo(
// We must query the server to know if the etag has not changed
_pendingAsyncJobs++;
QString serverOriginalPath = _discoveryData->_remoteFolder + _discoveryData->adjustRenamedPath(originalPath, SyncFileItem::Down);
- if (base.isVirtualFile() && isVfsWithSuffix())
- chopVirtualFileSuffix(serverOriginalPath);
+ if (base.isVirtualFile() && isVfsWithSuffix()) {
+ serverOriginalPath = chopVirtualFileSuffix(serverOriginalPath);
+ }
auto job = new RequestEtagJob(_discoveryData->_account, serverOriginalPath, this);
connect(job, &RequestEtagJob::finishedWithResult, this, [=](const HttpResult<QByteArray> &etag) mutable {
if (!etag || (etag.get() != base._etag && !item->isDirectory()) || _discoveryData->isRenamed(originalPath)) {
@@ -1367,14 +1368,13 @@ bool ProcessDirectoryJob::hasVirtualFileSuffix(const QString &str) const
return str.endsWith(_discoveryData->_syncOptions._vfs->fileSuffix());
}
-void ProcessDirectoryJob::chopVirtualFileSuffix(QString &str) const
+QString ProcessDirectoryJob::chopVirtualFileSuffix(const QString &str) const
{
if (!isVfsWithSuffix())
- return;
- bool hasSuffix = hasVirtualFileSuffix(str);
- OC_ASSERT(hasSuffix);
- if (hasSuffix)
- str.chop(_discoveryData->_syncOptions._vfs->fileSuffix().size());
+ return str;
+ // ensure we do it only with virtual files in this class
+ Q_ASSERT(hasVirtualFileSuffix(str));
+ return _discoveryData->_syncOptions._vfs->underlyingFileName(str);
}
DiscoverySingleDirectoryJob *ProcessDirectoryJob::startAsyncServerQuery()
diff --git a/src/libsync/discovery.h b/src/libsync/discovery.h
index 1b32958d7..64da6bb1e 100644
--- a/src/libsync/discovery.h
+++ b/src/libsync/discovery.h
@@ -195,7 +195,7 @@ private:
void addVirtualFileSuffix(QString &str) const;
bool hasVirtualFileSuffix(const QString &str) const;
- void chopVirtualFileSuffix(QString &str) const;
+ Q_REQUIRED_RESULT QString chopVirtualFileSuffix(const QString &str) const;
/** Convenience to detect suffix-vfs modes */
bool isVfsWithSuffix() const;
diff --git a/src/libsync/syncfilestatustracker.cpp b/src/libsync/syncfilestatustracker.cpp
index 583aadd0a..37a8731be 100644
--- a/src/libsync/syncfilestatustracker.cpp
+++ b/src/libsync/syncfilestatustracker.cpp
@@ -125,7 +125,7 @@ SyncFileStatus SyncFileStatusTracker::fileStatus(const QString &relativePath)
// it's an acceptable compromize to treat all exclude types the same.
// Update: This extra check shouldn't hurt even though silently excluded files
// are now available via slotAddSilentlyExcluded().
- if (_syncEngine->excludedFiles().isExcluded(absolutePath,
+ if (_syncEngine->excludedFiles().isExcluded(_syncEngine->syncOptions()._vfs->underlyingFileName(absolutePath),
_syncEngine->localPath(),
_syncEngine->ignoreHiddenFiles())) {
return SyncFileStatus(SyncFileStatus::StatusExcluded);
diff --git a/src/libsync/vfs/suffix/vfs_suffix.cpp b/src/libsync/vfs/suffix/vfs_suffix.cpp
index 8f9353f47..49950dceb 100644
--- a/src/libsync/vfs/suffix/vfs_suffix.cpp
+++ b/src/libsync/vfs/suffix/vfs_suffix.cpp
@@ -77,11 +77,8 @@ Result<Vfs::ConvertToPlaceholderResult, QString> VfsSuffix::updateMetadata(const
Result<void, QString> VfsSuffix::createPlaceholder(const SyncFileItem &item)
{
// The concrete shape of the placeholder is also used in isDehydratedPlaceholder() below
- QString fn = _setupParams.filesystemPath + item._file;
- if (!fn.endsWith(fileSuffix())) {
- OC_ASSERT_X(false, "vfs file isn't ending with suffix");
- return QStringLiteral("vfs file isn't ending with suffix");
- }
+ const QString fn = _setupParams.filesystemPath + item._file;
+ Q_ASSERT(fn.endsWith(fileSuffix()));
QFile file(fn);
if (file.exists() && file.size() > 1
@@ -146,4 +143,14 @@ Vfs::AvailabilityResult VfsSuffix::availability(const QString &folderPath)
return availabilityInDb(folderPath);
}
+QString VfsSuffix::underlyingFileName(const QString &fileName) const
+{
+ {
+ if (fileName.endsWith(fileSuffix())) {
+ return fileName.chopped(fileSuffix().size());
+ }
+ return fileName;
+ }
+}
+
} // namespace OCC
diff --git a/src/libsync/vfs/suffix/vfs_suffix.h b/src/libsync/vfs/suffix/vfs_suffix.h
index a9911605f..f73a964b5 100644
--- a/src/libsync/vfs/suffix/vfs_suffix.h
+++ b/src/libsync/vfs/suffix/vfs_suffix.h
@@ -31,6 +31,8 @@ public:
Mode mode() const override;
QString fileSuffix() const override;
+ QString underlyingFileName(const QString &fileName) const override;
+
void stop() override;
void unregisterFolder() override;