mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
Settings: Make FoldersWithPlaceholders group sticky
If virtual files are disabled on a folder it might still have db entries or local virtual files that would confuse older client versions.
This commit is contained in:
parent
ab85c60205
commit
7de453d439
@ -60,7 +60,6 @@ Folder::Folder(const FolderDefinition &definition,
|
||||
, _consecutiveFollowUpSyncs(0)
|
||||
, _journal(_definition.absoluteJournalPath())
|
||||
, _fileLog(new SyncRunFileLog)
|
||||
, _saveBackwardsCompatible(false)
|
||||
{
|
||||
_timeSinceLastSyncStart.start();
|
||||
_timeSinceLastSyncDone.start();
|
||||
@ -548,6 +547,8 @@ void Folder::downloadVirtualFile(const QString &_relativepath)
|
||||
void Folder::setUseVirtualFiles(bool enabled)
|
||||
{
|
||||
_definition.useVirtualFiles = enabled;
|
||||
if (enabled)
|
||||
_saveInFoldersWithPlaceholders = true;
|
||||
saveToSettings();
|
||||
}
|
||||
|
||||
@ -565,9 +566,9 @@ void Folder::saveToSettings() const
|
||||
return other != this && other->cleanPath() == this->cleanPath();
|
||||
});
|
||||
|
||||
if (_definition.useVirtualFiles) {
|
||||
// If virtual files are enabled, save the folder to a group
|
||||
// that will not be read by older (<2.5.0) clients.
|
||||
if (_definition.useVirtualFiles || _saveInFoldersWithPlaceholders) {
|
||||
// If virtual files are enabled or even were enabled at some point,
|
||||
// save the folder to a group that will not be read by older (<2.5.0) clients.
|
||||
// The name is from when virtual files were called placeholders.
|
||||
settingsGroup = QStringLiteral("FoldersWithPlaceholders");
|
||||
} else if (_saveBackwardsCompatible || oneAccountOnly) {
|
||||
|
||||
@ -227,6 +227,9 @@ public:
|
||||
*/
|
||||
void setSaveBackwardsCompatible(bool save);
|
||||
|
||||
/** Used to have placeholders: save in placeholder config section */
|
||||
void setSaveInFoldersWithPlaceholders() { _saveInFoldersWithPlaceholders = true; }
|
||||
|
||||
/**
|
||||
* Sets up this folder's folderWatcher if possible.
|
||||
*
|
||||
@ -388,7 +391,16 @@ private:
|
||||
* on the *first* Folder instance that was configured for each local
|
||||
* path.
|
||||
*/
|
||||
bool _saveBackwardsCompatible;
|
||||
bool _saveBackwardsCompatible = false;
|
||||
|
||||
/** Whether the folder should be saved in that settings group
|
||||
*
|
||||
* If it was read from there it had virtual files enabled at some
|
||||
* point and might still have db entries or suffix-virtual files even
|
||||
* if they are disabled right now. This flag ensures folders that
|
||||
* were in that group once never go back.
|
||||
*/
|
||||
bool _saveInFoldersWithPlaceholders = false;
|
||||
|
||||
/**
|
||||
* Watches this folder's local directory for changes.
|
||||
|
||||
@ -186,22 +186,22 @@ int FolderMan::setupFolders()
|
||||
|
||||
// The "backwardsCompatible" flag here is related to migrating old
|
||||
// database locations
|
||||
auto process = [&](const QString &groupName, bool backwardsCompatible = false) {
|
||||
auto process = [&](const QString &groupName, bool backwardsCompatible, bool foldersWithPlaceholders) {
|
||||
settings->beginGroup(groupName);
|
||||
if (skipSettingsKeys.contains(settings->group())) {
|
||||
// Should not happen: bad container keys should have been deleted
|
||||
qCWarning(lcFolderMan) << "Folder structure" << groupName << "is too new, ignoring";
|
||||
} else {
|
||||
setupFoldersHelper(*settings, account, backwardsCompatible, skipSettingsKeys);
|
||||
setupFoldersHelper(*settings, account, skipSettingsKeys, backwardsCompatible, foldersWithPlaceholders);
|
||||
}
|
||||
settings->endGroup();
|
||||
};
|
||||
|
||||
process(QStringLiteral("Folders"), true);
|
||||
process(QStringLiteral("Folders"), true, false);
|
||||
|
||||
// See Folder::saveToSettings for details about why these exists.
|
||||
process(QStringLiteral("Multifolders"));
|
||||
process(QStringLiteral("FoldersWithPlaceholders"));
|
||||
process(QStringLiteral("Multifolders"), false, false);
|
||||
process(QStringLiteral("FoldersWithPlaceholders"), false, true);
|
||||
|
||||
settings->endGroup(); // <account>
|
||||
}
|
||||
@ -211,7 +211,7 @@ int FolderMan::setupFolders()
|
||||
return _folderMap.size();
|
||||
}
|
||||
|
||||
void FolderMan::setupFoldersHelper(QSettings &settings, AccountStatePtr account, bool backwardsCompatible, const QStringList &ignoreKeys)
|
||||
void FolderMan::setupFoldersHelper(QSettings &settings, AccountStatePtr account, const QStringList &ignoreKeys, bool backwardsCompatible, bool foldersWithPlaceholders)
|
||||
{
|
||||
for (const auto &folderAlias : settings.childGroups()) {
|
||||
// Skip folders with too-new version
|
||||
@ -285,9 +285,10 @@ void FolderMan::setupFoldersHelper(QSettings &settings, AccountStatePtr account,
|
||||
Folder *f = addFolderInternal(std::move(folderDefinition), account.data());
|
||||
if (f) {
|
||||
// Migration: Mark folders that shall be saved in a backwards-compatible way
|
||||
if (backwardsCompatible) {
|
||||
if (backwardsCompatible)
|
||||
f->setSaveBackwardsCompatible(true);
|
||||
}
|
||||
if (foldersWithPlaceholders)
|
||||
f->setSaveInFoldersWithPlaceholders();
|
||||
scheduleFolder(f);
|
||||
emit folderSyncStateChange(f);
|
||||
}
|
||||
|
||||
@ -305,7 +305,7 @@ private:
|
||||
// restarts the application (Linux only)
|
||||
void restartApplication();
|
||||
|
||||
void setupFoldersHelper(QSettings &settings, AccountStatePtr account, bool backwardsCompatible, const QStringList &ignoreKeys);
|
||||
void setupFoldersHelper(QSettings &settings, AccountStatePtr account, const QStringList &ignoreKeys, bool backwardsCompatible, bool foldersWithPlaceholders);
|
||||
|
||||
QSet<Folder *> _disabledFolders;
|
||||
Folder::Map _folderMap;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user