diff options
author | Christian Kamm <mail@ckamm.de> | 2018-04-18 12:02:53 +0300 |
---|---|---|
committer | Christian Kamm <mail@ckamm.de> | 2018-04-18 12:02:53 +0300 |
commit | 9e8464e1149f79e77ba1807a03520ae9d90cc84a (patch) | |
tree | b2afca52539b5aef9c50a181c47444531d8424fa /src/libsync | |
parent | 57044c1e02934e3aecf637371efe56dc00d0ecf6 (diff) | |
parent | a9561f494b6b6259ed7fb5f0e05e23f6e423f21d (diff) |
Merge branch 'placeholder-prototype'
Diffstat (limited to 'src/libsync')
-rw-r--r-- | src/libsync/configfile.cpp | 7 | ||||
-rw-r--r-- | src/libsync/configfile.h | 3 | ||||
-rw-r--r-- | src/libsync/owncloudpropagator.cpp | 5 | ||||
-rw-r--r-- | src/libsync/owncloudpropagator.h | 1 | ||||
-rw-r--r-- | src/libsync/propagatedownload.cpp | 23 | ||||
-rw-r--r-- | src/libsync/propagatorjobs.cpp | 1 | ||||
-rw-r--r-- | src/libsync/syncengine.cpp | 10 | ||||
-rw-r--r-- | src/libsync/syncengine.h | 1 | ||||
-rw-r--r-- | src/libsync/syncoptions.h | 4 |
9 files changed, 53 insertions, 2 deletions
diff --git a/src/libsync/configfile.cpp b/src/libsync/configfile.cpp index d82e22e01..d0dadbf0f 100644 --- a/src/libsync/configfile.cpp +++ b/src/libsync/configfile.cpp @@ -65,6 +65,7 @@ static const char minChunkSizeC[] = "minChunkSize"; static const char maxChunkSizeC[] = "maxChunkSize"; static const char targetChunkUploadDurationC[] = "targetChunkUploadDuration"; static const char automaticLogDirC[] = "logToTemporaryLogDir"; +static const char showExperimentalOptionsC[] = "showExperimentalOptions"; static const char proxyHostC[] = "Proxy/host"; static const char proxyTypeC[] = "Proxy/type"; @@ -749,6 +750,12 @@ void ConfigFile::setAutomaticLogDir(bool enabled) settings.setValue(QLatin1String(automaticLogDirC), enabled); } +bool ConfigFile::showExperimentalOptions() const +{ + QSettings settings(configFile(), QSettings::IniFormat); + return settings.value(QLatin1String(showExperimentalOptionsC), false).toBool(); +} + QString ConfigFile::certificatePath() const { return retrieveData(QString(), QLatin1String(certPath)).toString(); diff --git a/src/libsync/configfile.h b/src/libsync/configfile.h index 901dab528..99aa6d5f1 100644 --- a/src/libsync/configfile.h +++ b/src/libsync/configfile.h @@ -92,6 +92,9 @@ public: bool automaticLogDir() const; void setAutomaticLogDir(bool enabled); + // Whether experimental UI options should be shown + bool showExperimentalOptions() const; + // proxy settings void setProxyType(int proxyType, const QString &host = QString(), diff --git a/src/libsync/owncloudpropagator.cpp b/src/libsync/owncloudpropagator.cpp index 6ac8da4ae..3cd8ab0be 100644 --- a/src/libsync/owncloudpropagator.cpp +++ b/src/libsync/owncloudpropagator.cpp @@ -589,6 +589,11 @@ QString OwncloudPropagator::getFilePath(const QString &tmp_file_name) const return _localDir + tmp_file_name; } +QString OwncloudPropagator::addPlaceholderSuffix(const QString &fileName) const +{ + return fileName + _syncOptions._placeholderSuffix; +} + void OwncloudPropagator::scheduleNextJob() { QTimer::singleShot(0, this, &OwncloudPropagator::scheduleNextJobImpl); diff --git a/src/libsync/owncloudpropagator.h b/src/libsync/owncloudpropagator.h index e5c42d284..b4bc470d2 100644 --- a/src/libsync/owncloudpropagator.h +++ b/src/libsync/owncloudpropagator.h @@ -451,6 +451,7 @@ public: bool hasCaseClashAccessibilityProblem(const QString &relfile); QString getFilePath(const QString &tmp_file_name) const; + QString addPlaceholderSuffix(const QString &fileName) const; /** Creates the job for an item. */ diff --git a/src/libsync/propagatedownload.cpp b/src/libsync/propagatedownload.cpp index 0601e9fba..77ce71386 100644 --- a/src/libsync/propagatedownload.cpp +++ b/src/libsync/propagatedownload.cpp @@ -348,6 +348,29 @@ void PropagateDownloadFile::start() qCDebug(lcPropagateDownload) << _item->_file << propagator()->_activeJobList.count(); _stopwatch.start(); + // For placeholder files just create the file and be done + if (_item->_type == ItemTypePlaceholder) { + auto fn = propagator()->getFilePath(_item->_file); + qCDebug(lcPropagateDownload) << "creating placeholder file" << fn; + QFile file(fn); + file.open(QFile::ReadWrite); + file.write("stub"); + file.close(); + updateMetadata(false); + return; + } + + // If we want to download something that used to be a placeholder, + // wipe the placeholder and proceed with a normal download + if (_item->_type == ItemTypePlaceholderDownload) { + auto placeholder = propagator()->addPlaceholderSuffix(_item->_file); + auto fn = propagator()->getFilePath(placeholder); + qCDebug(lcPropagateDownload) << "Downloading file that used to be a placeholder" << fn; + QFile::remove(fn); + propagator()->_journal->deleteFileRecord(placeholder); + _item->_type = ItemTypeFile; + } + if (_deleteExisting) { deleteExistingFolder(); diff --git a/src/libsync/propagatorjobs.cpp b/src/libsync/propagatorjobs.cpp index 1634599d4..b5b99f1d3 100644 --- a/src/libsync/propagatorjobs.cpp +++ b/src/libsync/propagatorjobs.cpp @@ -116,7 +116,6 @@ void PropagateLocalRemove::start() return; QString filename = propagator()->_localDir + _item->_file; - qCDebug(lcPropagateLocalRemove) << filename; if (propagator()->localFileNameClash(_item->_file)) { diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp index 665ae9652..64481ca60 100644 --- a/src/libsync/syncengine.cpp +++ b/src/libsync/syncengine.cpp @@ -614,7 +614,7 @@ int SyncEngine::treewalkFile(csync_file_stat_t *file, csync_file_stat_t *other, if (remote) { QString filePath = _localPath + item->_file; - if (other) { + if (other && other->type != ItemTypePlaceholder && other->type != ItemTypePlaceholderDownload) { // Even if the mtime is different on the server, we always want to keep the mtime from // the file system in the DB, this is to avoid spurious upload on the next sync item->_modtime = other->modtime; @@ -851,6 +851,14 @@ void SyncEngine::startSync() return shouldDiscoverLocally(path); }; + _csync_ctx->new_files_are_placeholders = _syncOptions._newFilesArePlaceholders; + _csync_ctx->placeholder_suffix = _syncOptions._placeholderSuffix.toUtf8(); + if (_csync_ctx->new_files_are_placeholders && _csync_ctx->placeholder_suffix.isEmpty()) { + csyncError(tr("Using placeholder files, but placeholder suffix is not set")); + finalize(false); + return; + } + bool ok; auto selectiveSyncBlackList = _journal->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, &ok); if (ok) { diff --git a/src/libsync/syncengine.h b/src/libsync/syncengine.h index 478a4703f..e00034f4d 100644 --- a/src/libsync/syncengine.h +++ b/src/libsync/syncengine.h @@ -76,6 +76,7 @@ public: bool isSyncRunning() const { return _syncRunning; } + SyncOptions syncOptions() const { return _syncOptions; } void setSyncOptions(const SyncOptions &options) { _syncOptions = options; } bool ignoreHiddenFiles() const { return _csync_ctx->ignore_hidden_files; } void setIgnoreHiddenFiles(bool ignore) { _csync_ctx->ignore_hidden_files = ignore; } diff --git a/src/libsync/syncoptions.h b/src/libsync/syncoptions.h index 676bfbeb7..ea48cd83e 100644 --- a/src/libsync/syncoptions.h +++ b/src/libsync/syncoptions.h @@ -36,6 +36,10 @@ struct SyncOptions /** If remotely deleted files are needed to move to trash */ bool _moveFilesToTrash = false; + /** Create a placeholder for new files instead of downloading */ + bool _newFilesArePlaceholders = false; + QString _placeholderSuffix = ".owncloud"; + /** The initial un-adjusted chunk size in bytes for chunked uploads, both * for old and new chunking algorithm, which classifies the item to be chunked * |