From 79df156a9abb265ae73fb5fd99a84715abd8233a Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Fri, 22 Mar 2024 17:24:40 +0100 Subject: [PATCH] context menu: do not recursively check pin and availability states Signed-off-by: Matthieu Gallien --- src/common/vfs.h | 13 +++++-- src/gui/socketapi/socketapi.cpp | 2 +- src/libsync/discovery.cpp | 2 +- src/libsync/vfs/cfapi/vfs_cfapi.cpp | 55 ++++++++++++++++++--------- src/libsync/vfs/cfapi/vfs_cfapi.h | 2 +- src/libsync/vfs/suffix/vfs_suffix.cpp | 3 +- src/libsync/vfs/suffix/vfs_suffix.h | 2 +- src/libsync/vfs/xattr/vfs_xattr.cpp | 3 +- src/libsync/vfs/xattr/vfs_xattr.h | 2 +- test/testsynccfapi.cpp | 30 +++++++-------- test/testsyncvirtualfiles.cpp | 30 +++++++-------- test/testsyncxattr.cpp | 30 +++++++-------- 12 files changed, 101 insertions(+), 73 deletions(-) diff --git a/src/common/vfs.h b/src/common/vfs.h index efe2e6654405f..3f6ea054db07b 100644 --- a/src/common/vfs.h +++ b/src/common/vfs.h @@ -134,8 +134,15 @@ class OCSYNC_EXPORT Vfs : public QObject // Availability not available since the item doesn't exist NoSuchItem, }; + Q_ENUM(AvailabilityError) using AvailabilityResult = Result; + enum class AvailabilityRecursivity { + RecursiveAvailability, + NotRecursiveAvailability, + }; + Q_ENUM(AvailabilityRecursivity) + public: explicit Vfs(QObject* parent = nullptr); ~Vfs() override; @@ -258,7 +265,7 @@ class OCSYNC_EXPORT Vfs : public QObject * * folderPath is relative to the sync folder. Can be "" for root folder. */ - Q_REQUIRED_RESULT virtual AvailabilityResult availability(const QString &folderPath) = 0; + Q_REQUIRED_RESULT virtual AvailabilityResult availability(const QString &folderPath, const AvailabilityRecursivity recursiveCheck) = 0; public slots: /** Update in-sync state based on SyncFileStatusTracker signal. @@ -320,7 +327,7 @@ class OCSYNC_EXPORT VfsOff : public Vfs Result updateMetadata(const QString &, time_t, qint64, const QByteArray &) override { return {}; } Result createPlaceholder(const SyncFileItem &) override { return {}; } Result dehydratePlaceholder(const SyncFileItem &) override { return {}; } - Result convertToPlaceholder(const QString &, const SyncFileItem &, const QString &, UpdateMetadataTypes) override { return ConvertToPlaceholderResult::Ok; } + Result convertToPlaceholder(const QString &, const SyncFileItem &, const QString &, const UpdateMetadataTypes) override { return ConvertToPlaceholderResult::Ok; } bool needsMetadataUpdate(const SyncFileItem &) override { return false; } bool isDehydratedPlaceholder(const QString &) override { return false; } @@ -328,7 +335,7 @@ class OCSYNC_EXPORT VfsOff : public Vfs bool setPinState(const QString &, PinState) override { return true; } Optional pinState(const QString &) override { return PinState::AlwaysLocal; } - AvailabilityResult availability(const QString &) override { return VfsItemAvailability::AlwaysLocal; } + AvailabilityResult availability(const QString &, AvailabilityRecursivity) override { return VfsItemAvailability::AlwaysLocal; } public slots: void fileStatusChanged(const QString &, OCC::SyncFileStatus) override {} diff --git a/src/gui/socketapi/socketapi.cpp b/src/gui/socketapi/socketapi.cpp index 78af17b4153e1..45e517183f855 100644 --- a/src/gui/socketapi/socketapi.cpp +++ b/src/gui/socketapi/socketapi.cpp @@ -1459,7 +1459,7 @@ void SocketApi::command_GET_MENU_ITEMS(const QString &argument, OCC::SocketListe }; for (const auto &file : files) { auto fileData = FileData::get(file); - auto availability = syncFolder->vfs().availability(fileData.folderRelativePath); + auto availability = syncFolder->vfs().availability(fileData.folderRelativePath, Vfs::AvailabilityRecursivity::NotRecursiveAvailability); if (!availability) { if (availability.error() == Vfs::AvailabilityError::DbError) availability = VfsItemAvailability::Mixed; diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index 1f10888f3a12d..2fc2b5bf26d8c 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -1290,7 +1290,7 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo( const bool isFilePlaceHolder = !localEntry.isDirectory && _discoveryData->_syncOptions._vfs->isDehydratedPlaceholder(_discoveryData->_localDir + path._local); // either correct availability, or a result with error if the folder is new or otherwise has no availability set yet - const auto folderPlaceHolderAvailability = localEntry.isDirectory ? _discoveryData->_syncOptions._vfs->availability(path._local) : Vfs::AvailabilityResult(Vfs::AvailabilityError::NoSuchItem); + const auto folderPlaceHolderAvailability = localEntry.isDirectory ? _discoveryData->_syncOptions._vfs->availability(path._local, Vfs::AvailabilityRecursivity::RecursiveAvailability) : Vfs::AvailabilityResult(Vfs::AvailabilityError::NoSuchItem); const auto folderPinState = localEntry.isDirectory ? _discoveryData->_syncOptions._vfs->pinState(path._local) : Optional(PinState::Unspecified); diff --git a/src/libsync/vfs/cfapi/vfs_cfapi.cpp b/src/libsync/vfs/cfapi/vfs_cfapi.cpp index 7e9e7bb8114ad..165e558cf0fe7 100644 --- a/src/libsync/vfs/cfapi/vfs_cfapi.cpp +++ b/src/libsync/vfs/cfapi/vfs_cfapi.cpp @@ -334,28 +334,47 @@ Optional VfsCfApi::pinStateLocal(const QString &localPath) const return info.pinState(); } -Vfs::AvailabilityResult VfsCfApi::availability(const QString &folderPath) +Vfs::AvailabilityResult VfsCfApi::availability(const QString &folderPath, const AvailabilityRecursivity recursiveCheck) { const auto basePinState = pinState(folderPath); - const auto hydrationAndPinStates = computeRecursiveHydrationAndPinStates(folderPath, basePinState); - - const auto pin = hydrationAndPinStates.pinState; - const auto hydrationStatus = hydrationAndPinStates.hydrationStatus; - - if (hydrationStatus.hasDehydrated) { - if (hydrationStatus.hasHydrated) - return VfsItemAvailability::Mixed; - if (pin && *pin == PinState::OnlineOnly) - return VfsItemAvailability::OnlineOnly; - else - return VfsItemAvailability::AllDehydrated; - } else if (hydrationStatus.hasHydrated) { - if (pin && *pin == PinState::AlwaysLocal) + if (basePinState && recursiveCheck == Vfs::AvailabilityRecursivity::NotRecursiveAvailability) { + switch (*basePinState) + { + case OCC::PinState::AlwaysLocal: return VfsItemAvailability::AlwaysLocal; - else - return VfsItemAvailability::AllHydrated; + break; + case OCC::PinState::Excluded: + break; + case OCC::PinState::Inherited: + break; + case OCC::PinState::OnlineOnly: + return VfsItemAvailability::OnlineOnly; + break; + case OCC::PinState::Unspecified: + break; + }; + return VfsItemAvailability::Mixed; + } else { + const auto hydrationAndPinStates = computeRecursiveHydrationAndPinStates(folderPath, basePinState); + + const auto pin = hydrationAndPinStates.pinState; + const auto hydrationStatus = hydrationAndPinStates.hydrationStatus; + + if (hydrationStatus.hasDehydrated) { + if (hydrationStatus.hasHydrated) + return VfsItemAvailability::Mixed; + if (pin && *pin == PinState::OnlineOnly) + return VfsItemAvailability::OnlineOnly; + else + return VfsItemAvailability::AllDehydrated; + } else if (hydrationStatus.hasHydrated) { + if (pin && *pin == PinState::AlwaysLocal) + return VfsItemAvailability::AlwaysLocal; + else + return VfsItemAvailability::AllHydrated; + } + return AvailabilityError::NoSuchItem; } - return AvailabilityError::NoSuchItem; } HydrationJob *VfsCfApi::findHydrationJob(const QString &requestId) const diff --git a/src/libsync/vfs/cfapi/vfs_cfapi.h b/src/libsync/vfs/cfapi/vfs_cfapi.h index ce0d97ea0ccb2..38e04e00ef446 100644 --- a/src/libsync/vfs/cfapi/vfs_cfapi.h +++ b/src/libsync/vfs/cfapi/vfs_cfapi.h @@ -53,7 +53,7 @@ class VfsCfApi : public Vfs bool setPinState(const QString &folderPath, PinState state) override; Optional pinState(const QString &folderPath) override; - AvailabilityResult availability(const QString &folderPath) override; + AvailabilityResult availability(const QString &folderPath, const AvailabilityRecursivity recursiveCheck) override; void cancelHydration(const QString &requestId, const QString &path); diff --git a/src/libsync/vfs/suffix/vfs_suffix.cpp b/src/libsync/vfs/suffix/vfs_suffix.cpp index d82422787e279..71dd2b9774b37 100644 --- a/src/libsync/vfs/suffix/vfs_suffix.cpp +++ b/src/libsync/vfs/suffix/vfs_suffix.cpp @@ -169,8 +169,9 @@ bool VfsSuffix::setPinState(const QString &folderPath, PinState state) return setPinStateInDb(folderPath, state); } -Vfs::AvailabilityResult VfsSuffix::availability(const QString &folderPath) +Vfs::AvailabilityResult VfsSuffix::availability(const QString &folderPath, const AvailabilityRecursivity recursiveCheck) { + Q_UNUSED(recursiveCheck) return availabilityInDb(folderPath); } diff --git a/src/libsync/vfs/suffix/vfs_suffix.h b/src/libsync/vfs/suffix/vfs_suffix.h index 3164802d9c83d..85e39b1b00d92 100644 --- a/src/libsync/vfs/suffix/vfs_suffix.h +++ b/src/libsync/vfs/suffix/vfs_suffix.h @@ -51,7 +51,7 @@ class VfsSuffix : public Vfs bool setPinState(const QString &folderPath, PinState state) override; Optional pinState(const QString &folderPath) override { return pinStateInDb(folderPath); } - AvailabilityResult availability(const QString &folderPath) override; + AvailabilityResult availability(const QString &folderPath, const AvailabilityRecursivity recursiveCheck) override; public slots: void fileStatusChanged(const QString &, OCC::SyncFileStatus) override {} diff --git a/src/libsync/vfs/xattr/vfs_xattr.cpp b/src/libsync/vfs/xattr/vfs_xattr.cpp index cf553eb37c5fd..cf81294e9c247 100644 --- a/src/libsync/vfs/xattr/vfs_xattr.cpp +++ b/src/libsync/vfs/xattr/vfs_xattr.cpp @@ -188,8 +188,9 @@ Optional VfsXAttr::pinState(const QString &folderPath) return pinStateInDb(folderPath); } -Vfs::AvailabilityResult VfsXAttr::availability(const QString &folderPath) +Vfs::AvailabilityResult VfsXAttr::availability(const QString &folderPath, const AvailabilityRecursivity recursiveCheck) { + Q_UNUSED(recursiveCheck) return availabilityInDb(folderPath); } diff --git a/src/libsync/vfs/xattr/vfs_xattr.h b/src/libsync/vfs/xattr/vfs_xattr.h index b9fc9548c4707..de331f4a7a877 100644 --- a/src/libsync/vfs/xattr/vfs_xattr.h +++ b/src/libsync/vfs/xattr/vfs_xattr.h @@ -53,7 +53,7 @@ class VfsXAttr : public Vfs bool setPinState(const QString &folderPath, PinState state) override; Optional pinState(const QString &folderPath) override; - AvailabilityResult availability(const QString &folderPath) override; + AvailabilityResult availability(const QString &folderPath, const AvailabilityRecursivity recursiveCheck) override; public slots: void fileStatusChanged(const QString &systemFileName, OCC::SyncFileStatus fileStatus) override; diff --git a/test/testsynccfapi.cpp b/test/testsynccfapi.cpp index dd6fd80eb1fee..36d8fe9658ac7 100644 --- a/test/testsynccfapi.cpp +++ b/test/testsynccfapi.cpp @@ -1032,37 +1032,37 @@ private slots: QVERIFY(fakeFolder.syncOnce()); // root is unspecified - QCOMPARE(*vfs->availability("file1"), VfsItemAvailability::AllDehydrated); - QCOMPARE(*vfs->availability("local"), VfsItemAvailability::AlwaysLocal); - QCOMPARE(*vfs->availability("local/file1"), VfsItemAvailability::AlwaysLocal); - QCOMPARE(*vfs->availability("online"), VfsItemAvailability::OnlineOnly); - QCOMPARE(*vfs->availability("online/file1"), VfsItemAvailability::OnlineOnly); - QCOMPARE(*vfs->availability("unspec"), VfsItemAvailability::AllDehydrated); - QCOMPARE(*vfs->availability("unspec/file1"), VfsItemAvailability::AllDehydrated); + QCOMPARE(*vfs->availability("file1", Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::AllDehydrated); + QCOMPARE(*vfs->availability("local", Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::AlwaysLocal); + QCOMPARE(*vfs->availability("local/file1", Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::AlwaysLocal); + QCOMPARE(*vfs->availability("online", Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::OnlineOnly); + QCOMPARE(*vfs->availability("online/file1", Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::OnlineOnly); + QCOMPARE(*vfs->availability("unspec", Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::AllDehydrated); + QCOMPARE(*vfs->availability("unspec/file1", Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::AllDehydrated); // Subitem pin states can ruin "pure" availabilities ::setPinState(fakeFolder.localPath() + "local/sub", PinState::OnlineOnly, cfapi::NoRecurse); - QCOMPARE(*vfs->availability("local"), VfsItemAvailability::AllHydrated); + QCOMPARE(*vfs->availability("local", Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::AllHydrated); ::setPinState(fakeFolder.localPath() + "online/sub", PinState::Unspecified, cfapi::NoRecurse); - QCOMPARE(*vfs->availability("online"), VfsItemAvailability::AllDehydrated); + QCOMPARE(*vfs->availability("online", Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::AllDehydrated); triggerDownload(fakeFolder, "unspec/file1"); ::setPinState(fakeFolder.localPath() + "local/file2", PinState::OnlineOnly, cfapi::NoRecurse); ::setPinState(fakeFolder.localPath() + "online/file2", PinState::AlwaysLocal, cfapi::NoRecurse); QVERIFY(fakeFolder.syncOnce()); - QCOMPARE(*vfs->availability("unspec"), VfsItemAvailability::AllHydrated); - QCOMPARE(*vfs->availability("local"), VfsItemAvailability::Mixed); - QCOMPARE(*vfs->availability("online"), VfsItemAvailability::Mixed); + QCOMPARE(*vfs->availability("unspec", Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::AllHydrated); + QCOMPARE(*vfs->availability("local", Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::Mixed); + QCOMPARE(*vfs->availability("online", Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::Mixed); QVERIFY(vfs->setPinState("local", PinState::AlwaysLocal)); QVERIFY(vfs->setPinState("online", PinState::OnlineOnly)); QVERIFY(fakeFolder.syncOnce()); - QCOMPARE(*vfs->availability("online"), VfsItemAvailability::OnlineOnly); - QCOMPARE(*vfs->availability("local"), VfsItemAvailability::AlwaysLocal); + QCOMPARE(*vfs->availability("online", Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::OnlineOnly); + QCOMPARE(*vfs->availability("local", Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::AlwaysLocal); - auto r = vfs->availability("nonexistent"); + auto r = vfs->availability("nonexistent", Vfs::AvailabilityRecursivity::RecursiveAvailability); QVERIFY(!r); QCOMPARE(r.error(), Vfs::AvailabilityError::NoSuchItem); } diff --git a/test/testsyncvirtualfiles.cpp b/test/testsyncvirtualfiles.cpp index 26e8ffce90a54..c6e9dab8b99d2 100644 --- a/test/testsyncvirtualfiles.cpp +++ b/test/testsyncvirtualfiles.cpp @@ -1365,37 +1365,37 @@ private slots: QVERIFY(fakeFolder.syncOnce()); // root is unspecified - QCOMPARE(*vfs->availability("file1" DVSUFFIX), VfsItemAvailability::AllDehydrated); - QCOMPARE(*vfs->availability("local"), VfsItemAvailability::AlwaysLocal); - QCOMPARE(*vfs->availability("local/file1"), VfsItemAvailability::AlwaysLocal); - QCOMPARE(*vfs->availability("online"), VfsItemAvailability::OnlineOnly); - QCOMPARE(*vfs->availability("online/file1" DVSUFFIX), VfsItemAvailability::OnlineOnly); - QCOMPARE(*vfs->availability("unspec"), VfsItemAvailability::AllDehydrated); - QCOMPARE(*vfs->availability("unspec/file1" DVSUFFIX), VfsItemAvailability::AllDehydrated); + QCOMPARE(*vfs->availability("file1" DVSUFFIX, Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::AllDehydrated); + QCOMPARE(*vfs->availability("local", Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::AlwaysLocal); + QCOMPARE(*vfs->availability("local/file1", Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::AlwaysLocal); + QCOMPARE(*vfs->availability("online", Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::OnlineOnly); + QCOMPARE(*vfs->availability("online/file1" DVSUFFIX, Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::OnlineOnly); + QCOMPARE(*vfs->availability("unspec", Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::AllDehydrated); + QCOMPARE(*vfs->availability("unspec/file1" DVSUFFIX, Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::AllDehydrated); // Subitem pin states can ruin "pure" availabilities setPin("local/sub", PinState::OnlineOnly); - QCOMPARE(*vfs->availability("local"), VfsItemAvailability::AllHydrated); + QCOMPARE(*vfs->availability("local", Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::AllHydrated); setPin("online/sub", PinState::Unspecified); - QCOMPARE(*vfs->availability("online"), VfsItemAvailability::AllDehydrated); + QCOMPARE(*vfs->availability("online", Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::AllDehydrated); triggerDownload(fakeFolder, "unspec/file1"); setPin("local/file2", PinState::OnlineOnly); setPin("online/file2" DVSUFFIX, PinState::AlwaysLocal); QVERIFY(fakeFolder.syncOnce()); - QCOMPARE(*vfs->availability("unspec"), VfsItemAvailability::AllHydrated); - QCOMPARE(*vfs->availability("local"), VfsItemAvailability::Mixed); - QCOMPARE(*vfs->availability("online"), VfsItemAvailability::Mixed); + QCOMPARE(*vfs->availability("unspec", Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::AllHydrated); + QCOMPARE(*vfs->availability("local", Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::Mixed); + QCOMPARE(*vfs->availability("online", Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::Mixed); QVERIFY(vfs->setPinState("local", PinState::AlwaysLocal)); QVERIFY(vfs->setPinState("online", PinState::OnlineOnly)); QVERIFY(fakeFolder.syncOnce()); - QCOMPARE(*vfs->availability("online"), VfsItemAvailability::OnlineOnly); - QCOMPARE(*vfs->availability("local"), VfsItemAvailability::AlwaysLocal); + QCOMPARE(*vfs->availability("online", Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::OnlineOnly); + QCOMPARE(*vfs->availability("local", Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::AlwaysLocal); - auto r = vfs->availability("nonexistent"); + auto r = vfs->availability("nonexistent", Vfs::AvailabilityRecursivity::RecursiveAvailability); QVERIFY(!r); QCOMPARE(r.error(), Vfs::AvailabilityError::NoSuchItem); } diff --git a/test/testsyncxattr.cpp b/test/testsyncxattr.cpp index 670478a417e6d..ec735429a8ceb 100644 --- a/test/testsyncxattr.cpp +++ b/test/testsyncxattr.cpp @@ -932,37 +932,37 @@ private slots: QVERIFY(fakeFolder.syncOnce()); // root is unspecified - QCOMPARE(*vfs->availability("file1"), VfsItemAvailability::AllDehydrated); - QCOMPARE(*vfs->availability("local"), VfsItemAvailability::AlwaysLocal); - QCOMPARE(*vfs->availability("local/file1"), VfsItemAvailability::AlwaysLocal); - QCOMPARE(*vfs->availability("online"), VfsItemAvailability::OnlineOnly); - QCOMPARE(*vfs->availability("online/file1"), VfsItemAvailability::OnlineOnly); - QCOMPARE(*vfs->availability("unspec"), VfsItemAvailability::AllDehydrated); - QCOMPARE(*vfs->availability("unspec/file1"), VfsItemAvailability::AllDehydrated); + QCOMPARE(*vfs->availability("file1", Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::AllDehydrated); + QCOMPARE(*vfs->availability("local", Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::AlwaysLocal); + QCOMPARE(*vfs->availability("local/file1", Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::AlwaysLocal); + QCOMPARE(*vfs->availability("online", Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::OnlineOnly); + QCOMPARE(*vfs->availability("online/file1", Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::OnlineOnly); + QCOMPARE(*vfs->availability("unspec", Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::AllDehydrated); + QCOMPARE(*vfs->availability("unspec/file1", Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::AllDehydrated); // Subitem pin states can ruin "pure" availabilities setPin("local/sub", PinState::OnlineOnly); - QCOMPARE(*vfs->availability("local"), VfsItemAvailability::AllHydrated); + QCOMPARE(*vfs->availability("local", Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::AllHydrated); setPin("online/sub", PinState::Unspecified); - QCOMPARE(*vfs->availability("online"), VfsItemAvailability::AllDehydrated); + QCOMPARE(*vfs->availability("online", Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::AllDehydrated); triggerDownload(fakeFolder, "unspec/file1"); setPin("local/file2", PinState::OnlineOnly); setPin("online/file2", PinState::AlwaysLocal); QVERIFY(fakeFolder.syncOnce()); - QCOMPARE(*vfs->availability("unspec"), VfsItemAvailability::AllHydrated); - QCOMPARE(*vfs->availability("local"), VfsItemAvailability::Mixed); - QCOMPARE(*vfs->availability("online"), VfsItemAvailability::Mixed); + QCOMPARE(*vfs->availability("unspec", Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::AllHydrated); + QCOMPARE(*vfs->availability("local", Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::Mixed); + QCOMPARE(*vfs->availability("online", Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::Mixed); QVERIFY(vfs->setPinState("local", PinState::AlwaysLocal)); QVERIFY(vfs->setPinState("online", PinState::OnlineOnly)); QVERIFY(fakeFolder.syncOnce()); - QCOMPARE(*vfs->availability("online"), VfsItemAvailability::OnlineOnly); - QCOMPARE(*vfs->availability("local"), VfsItemAvailability::AlwaysLocal); + QCOMPARE(*vfs->availability("online", Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::OnlineOnly); + QCOMPARE(*vfs->availability("local", Vfs::AvailabilityRecursivity::RecursiveAvailability), VfsItemAvailability::AlwaysLocal); - auto r = vfs->availability("nonexistent"); + auto r = vfs->availability("nonexistent", Vfs::AvailabilityRecursivity::RecursiveAvailability); QVERIFY(!r); QCOMPARE(r.error(), Vfs::AvailabilityError::NoSuchItem); }