return;
}
- if (_relPathParent != QStringLiteral("/") && (!_fileParentItem || _fileParentItem->isEmpty())) {
+ if (!isFileParentItemValid()) {
showError(tr("Could not find a file for local editing. Make sure its path is valid and it is synced locally."), _relPath);
return;
}
// connect to a SyncEngine::itemDiscovered so we can complete the job as soon as the file in question is discovered
QObject::connect(&_folderForFile->syncEngine(), &SyncEngine::itemDiscovered, this, &EditLocallyJob::slotItemDiscovered);
- _folderForFile->syncEngine().setSingleItemDiscoveryOptions({_relPathParent == QStringLiteral("/") ? QString{} : _relPathParent, _relativePathToRemoteRoot, _fileParentItem});
+ _folderForFile->syncEngine().setSingleItemDiscoveryOptions({_relPathParent, _relativePathToRemoteRoot, _fileParentItem});
FolderMan::instance()->forceSyncForFolder(_folderForFile);
}
bool EditLocallyJob::eraseBlacklistRecordForItem()
{
- if (!_folderForFile || !_fileParentItem) {
+ if (!_folderForFile || !isFileParentItemValid()) {
qCWarning(lcEditLocallyJob) << "_folderForFile or _fileParentItem is invalid!";
return false;
}
+ if (!_fileParentItem && _relPathParent == QStringLiteral("/")) {
+ return true;
+ }
+
+ Q_ASSERT(_fileParentItem);
+ if (!_fileParentItem) {
+ qCWarning(lcEditLocallyJob) << "_fileParentItem is invalid!";
+ return false;
+ }
+
Q_ASSERT(!_folderForFile->isSyncRunning());
if (_folderForFile->isSyncRunning()) {
qCWarning(lcEditLocallyJob) << "_folderForFile is syncing";
};
const auto runSingleFileDiscovery = [this] {
- const SyncEngine::SingleItemDiscoveryOptions singleItemDiscoveryOptions = {(_relPathParent == QStringLiteral("/") ? QString{} : _relPathParent),
- _relativePathToRemoteRoot,
- _fileParentItem};
+ const SyncEngine::SingleItemDiscoveryOptions singleItemDiscoveryOptions = {_relPathParent, _relativePathToRemoteRoot, _fileParentItem};
_folderForFile->syncEngine().setSingleItemDiscoveryOptions(singleItemDiscoveryOptions);
FolderMan::instance()->forceSyncForFolder(_folderForFile);
};
return remainingTimeInMinutes;
}
+bool EditLocallyJob::isFileParentItemValid() const
+{
+ return (_fileParentItem && !_fileParentItem->isEmpty()) || _relPathParent == QStringLiteral("/");
+}
+
}
fullLocalDiscoveryInterval.count() >= 0 // negative means we don't require periodic full runs
&& _timeSinceLastFullLocalDiscovery.hasExpired(fullLocalDiscoveryInterval.count());
- if (!singleItemDiscoveryOptions.filePathRelative.isEmpty()
- && singleItemDiscoveryOptions.discoveryDirItem && !singleItemDiscoveryOptions.discoveryDirItem->isEmpty()) {
+ if (singleItemDiscoveryOptions.isValid() && singleItemDiscoveryOptions.discoveryPath != QStringLiteral("/")) {
qCInfo(lcFolder) << "Going to sync just one file";
_engine->setLocalDiscoveryOptions(LocalDiscoveryStyle::DatabaseAndFilesystem, {singleItemDiscoveryOptions.discoveryPath});
_localDiscoveryTracker->startSyncPartialDiscovery();
_excludedFiles.reset();
}
+bool SyncEngine::SingleItemDiscoveryOptions::isValid() const
+{
+ return !filePathRelative.isEmpty() && !discoveryPath.isEmpty()
+ && ((discoveryDirItem && !discoveryDirItem->isEmpty()) || discoveryPath == QStringLiteral("/"));
+}
+
/**
* Check if the item is in the blacklist.
* If it should not be sync'ed because of the blacklist, update the item with the error instruction
ProcessDirectoryJob *discoveryJob = nullptr;
- if (!singleItemDiscoveryOptions().filePathRelative.isEmpty()) {
+ if (singleItemDiscoveryOptions().isValid()) {
_discoveryPhase->_listExclusiveFiles.clear();
_discoveryPhase->_listExclusiveFiles.push_back(singleItemDiscoveryOptions().filePathRelative);
}
- if (!singleItemDiscoveryOptions().discoveryPath.isEmpty() && singleItemDiscoveryOptions().discoveryDirItem) {
+ if (singleItemDiscoveryOptions().isValid() && singleItemDiscoveryOptions().discoveryDirItem) {
ProcessDirectoryJob::PathTuple path = {};
path._local = path._original = path._server = path._target = singleItemDiscoveryOptions().discoveryPath;