mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
vfs: Make switching vfs on/off work again
This commit is contained in:
parent
fa6f3cd847
commit
4bef96afe7
@ -133,26 +133,8 @@ Folder::Folder(const FolderDefinition &definition,
|
||||
}
|
||||
|
||||
// Initialize the vfs plugin
|
||||
if (_definition.virtualFilesMode != Vfs::Off) {
|
||||
ENFORCE(_vfs);
|
||||
ENFORCE(_vfs->mode() == _definition.virtualFilesMode);
|
||||
|
||||
_vfs->setParent(this);
|
||||
|
||||
VfsSetupParams vfsParams;
|
||||
vfsParams.filesystemPath = path();
|
||||
vfsParams.remotePath = remotePath();
|
||||
vfsParams.account = _accountState->account();
|
||||
vfsParams.journal = &_journal;
|
||||
vfsParams.providerName = Theme::instance()->appNameGUI();
|
||||
vfsParams.providerVersion = Theme::instance()->version();
|
||||
|
||||
connect(_vfs, &OCC::Vfs::beginHydrating, this, &Folder::slotHydrationStarts);
|
||||
connect(_vfs, &OCC::Vfs::doneHydrating, this, &Folder::slotHydrationDone);
|
||||
|
||||
_vfs->registerFolder(vfsParams); // Do this always?
|
||||
_vfs->start(vfsParams);
|
||||
}
|
||||
if (_definition.virtualFilesMode != Vfs::Off)
|
||||
startVfs();
|
||||
}
|
||||
|
||||
Folder::~Folder()
|
||||
@ -485,6 +467,28 @@ void Folder::createGuiLog(const QString &filename, LogStatus status, int count,
|
||||
}
|
||||
}
|
||||
|
||||
void Folder::startVfs()
|
||||
{
|
||||
ENFORCE(_vfs);
|
||||
ENFORCE(_vfs->mode() == _definition.virtualFilesMode);
|
||||
|
||||
_vfs->setParent(this);
|
||||
|
||||
VfsSetupParams vfsParams;
|
||||
vfsParams.filesystemPath = path();
|
||||
vfsParams.remotePath = remotePath();
|
||||
vfsParams.account = _accountState->account();
|
||||
vfsParams.journal = &_journal;
|
||||
vfsParams.providerName = Theme::instance()->appNameGUI();
|
||||
vfsParams.providerVersion = Theme::instance()->version();
|
||||
|
||||
connect(_vfs, &OCC::Vfs::beginHydrating, this, &Folder::slotHydrationStarts);
|
||||
connect(_vfs, &OCC::Vfs::doneHydrating, this, &Folder::slotHydrationDone);
|
||||
|
||||
_vfs->registerFolder(vfsParams); // Do this always?
|
||||
_vfs->start(vfsParams);
|
||||
}
|
||||
|
||||
int Folder::slotDiscardDownloadProgress()
|
||||
{
|
||||
// Delete from journal and from filesystem.
|
||||
@ -592,10 +596,24 @@ void Folder::downloadVirtualFile(const QString &_relativepath)
|
||||
|
||||
void Folder::setUseVirtualFiles(bool enabled)
|
||||
{
|
||||
// ### must wipe virtual files, unload old plugin, load new one?
|
||||
//_definition.useVirtualFiles = enabled;
|
||||
if (enabled)
|
||||
if (enabled && _definition.virtualFilesMode == Vfs::Off) {
|
||||
_definition.virtualFilesMode = bestAvailableVfsMode();
|
||||
|
||||
_vfs = createVfsFromPlugin(_definition.virtualFilesMode, this);
|
||||
startVfs();
|
||||
|
||||
_saveInFoldersWithPlaceholders = true;
|
||||
}
|
||||
if (!enabled && _definition.virtualFilesMode != Vfs::Off) {
|
||||
// TODO: Must wait for current sync to finish!
|
||||
SyncEngine::wipeVirtualFiles(path(), _journal, _vfs);
|
||||
|
||||
_vfs->stop();
|
||||
_vfs->unregisterFolder();
|
||||
delete _vfs;
|
||||
|
||||
_definition.virtualFilesMode = Vfs::Off;
|
||||
}
|
||||
saveToSettings();
|
||||
}
|
||||
|
||||
|
||||
@ -381,6 +381,8 @@ private:
|
||||
void createGuiLog(const QString &filename, LogStatus status, int count,
|
||||
const QString &renameTarget = QString());
|
||||
|
||||
void startVfs();
|
||||
|
||||
AccountStatePtr _accountState;
|
||||
FolderDefinition _definition;
|
||||
QString _canonicalLocalPath; // As returned with QFileInfo:canonicalFilePath. Always ends with "/"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user