1
0
mirror of https://github.com/chylex/Nextcloud-Desktop.git synced 2025-05-02 03:34:03 +02:00

Rename Placeholders to Virtual Files in code

This commit is contained in:
Christian Kamm 2018-05-18 08:29:40 +02:00 committed by Kevin Ottens
parent a877a9d472
commit aa6f5f59c4
No known key found for this signature in database
GPG Key ID: 074BBBCB8DECC9E2
32 changed files with 211 additions and 210 deletions

View File

@ -14,8 +14,8 @@ else ()
endif() endif()
# Default suffix if the theme doesn't define one # Default suffix if the theme doesn't define one
if(NOT DEFINED APPLICATION_PLACEHOLDER_SUFFIX) if(NOT DEFINED APPLICATION_VIRTUALFILE_SUFFIX)
set(APPLICATION_PLACEHOLDER_SUFFIX "${APPLICATION_SHORTNAME}_placeholder" CACHE STRING "Placeholder suffix (not including the .)") set(APPLICATION_VIRTUALFILE_SUFFIX "${APPLICATION_SHORTNAME}_virtual" CACHE STRING "Virtual file suffix (not including the .)")
endif() endif()
# need this logic to not mess with re/uninstallations via macosx.pkgproj # need this logic to not mess with re/uninstallations via macosx.pkgproj

View File

@ -9,7 +9,7 @@ set( APPLICATION_ICON_NAME "Nextcloud" )
set( APPLICATION_SERVER_URL "" CACHE STRING "URL for the server to use. If entered, the UI field will be pre-filled with it" ) set( APPLICATION_SERVER_URL "" CACHE STRING "URL for the server to use. If entered, the UI field will be pre-filled with it" )
set( APPLICATION_SERVER_URL_ENFORCE ON ) # If set and APPLICATION_SERVER_URL is defined, the server can only connect to the pre-defined URL set( APPLICATION_SERVER_URL_ENFORCE ON ) # If set and APPLICATION_SERVER_URL is defined, the server can only connect to the pre-defined URL
set( APPLICATION_REV_DOMAIN "com.nextcloud.desktopclient" ) set( APPLICATION_REV_DOMAIN "com.nextcloud.desktopclient" )
set( APPLICATION_PLACEHOLDER_SUFFIX "nextcloud" CACHE STRING "Placeholder suffix (not including the .)") set( APPLICATION_VIRTUALFILE_SUFFIX "nextcloud" CACHE STRING "Virtual file suffix (not including the .)")
set( LINUX_PACKAGE_SHORTNAME "nextcloud" ) set( LINUX_PACKAGE_SHORTNAME "nextcloud" )
set( LINUX_APPLICATION_ID "${APPLICATION_REV_DOMAIN}.${LINUX_PACKAGE_SHORTNAME}") set( LINUX_APPLICATION_ID "${APPLICATION_REV_DOMAIN}.${LINUX_PACKAGE_SHORTNAME}")

View File

@ -41,11 +41,11 @@
<array> <array>
<dict> <dict>
<key>UTTypeIdentifier</key> <key>UTTypeIdentifier</key>
<string>@APPLICATION_REV_DOMAIN@.placeholder</string> <string>@APPLICATION_REV_DOMAIN@.VIRTUALFILE</string>
<key>UTTypeTagSpecification</key> <key>UTTypeTagSpecification</key>
<dict> <dict>
<key>public.filename-extension</key> <key>public.filename-extension</key>
<string>@APPLICATION_PLACEHOLDER_SUFFIX@</string> <string>@APPLICATION_VIRTUALFILE_SUFFIX@</string>
<key>public.mime-type</key> <key>public.mime-type</key>
<string>application/octet-stream</string> <string>application/octet-stream</string>
</dict> </dict>
@ -60,14 +60,14 @@
<array> <array>
<dict> <dict>
<key>CFBundleTypeName</key> <key>CFBundleTypeName</key>
<string>@APPLICATION_EXECUTABLE@ Download Placeholder</string> <string>@APPLICATION_EXECUTABLE@ Download Virtual File</string>
<key>CFBundleTypeRole</key> <key>CFBundleTypeRole</key>
<string>Editor</string> <string>Editor</string>
<key>LSHandlerRank</key> <key>LSHandlerRank</key>
<string>Owner</string> <string>Owner</string>
<key>LSItemContentTypes</key> <key>LSItemContentTypes</key>
<array> <array>
<string>@APPLICATION_REV_DOMAIN@.placeholder</string> <string>@APPLICATION_REV_DOMAIN@.VIRTUALFILE</string>
</array> </array>
</dict> </dict>
</array> </array>

View File

@ -7,8 +7,8 @@
!define APPLICATION_CMD_EXECUTABLE "@APPLICATION_EXECUTABLE@cmd.exe" !define APPLICATION_CMD_EXECUTABLE "@APPLICATION_EXECUTABLE@cmd.exe"
!define APPLICATION_DOMAIN "@APPLICATION_DOMAIN@" !define APPLICATION_DOMAIN "@APPLICATION_DOMAIN@"
!define APPLICATION_LICENSE "@APPLICATION_LICENSE@" !define APPLICATION_LICENSE "@APPLICATION_LICENSE@"
!define APPLICATION_PLACEHOLDER_SUFFIX "@APPLICATION_PLACEHOLDER_SUFFIX@" !define APPLICATION_VIRTUALFILE_SUFFIX "@APPLICATION_VIRTUALFILE_SUFFIX@"
!define APPLICATION_PLACEHOLDER_FILECLASS "@APPLICATION_EXECUTABLE@.@APPLICATION_PLACEHOLDER_SUFFIX@" !define APPLICATION_VIRTUALFILE_FILECLASS "@APPLICATION_EXECUTABLE@.@APPLICATION_VIRTUALFILE_SUFFIX@"
!define WIN_SETUP_BITMAP_PATH "@WIN_SETUP_BITMAP_PATH@" !define WIN_SETUP_BITMAP_PATH "@WIN_SETUP_BITMAP_PATH@"
!define CRASHREPORTER_EXECUTABLE "@CRASHREPORTER_EXECUTABLE@" !define CRASHREPORTER_EXECUTABLE "@CRASHREPORTER_EXECUTABLE@"
@ -474,7 +474,7 @@ Section "${APPLICATION_NAME}" SEC_APPLICATION
File "${SOURCE_PATH}/sync-exclude.lst" File "${SOURCE_PATH}/sync-exclude.lst"
;Add file association ;Add file association
!insertmacro APP_ASSOCIATE "${APPLICATION_PLACEHOLDER_SUFFIX}" "${APPLICATION_PLACEHOLDER_FILECLASS}" "Placeholder for Remote File" "$INSTDIR\${APPLICATION_EXECUTABLE},0" "Download" "$INSTDIR\${APPLICATION_EXECUTABLE} $\"%1$\"" !insertmacro APP_ASSOCIATE "${APPLICATION_VIRTUALFILE_SUFFIX}" "${APPLICATION_VIRTUALFILE_FILECLASS}" "Virtual File for Remote File" "$INSTDIR\${APPLICATION_EXECUTABLE},0" "Download" "$INSTDIR\${APPLICATION_EXECUTABLE} $\"%1$\""
SectionEnd SectionEnd
@ -654,7 +654,7 @@ Section Uninstall
DeleteRegKey HKCR "${APPLICATION_NAME}" DeleteRegKey HKCR "${APPLICATION_NAME}"
;Remove file association ;Remove file association
!insertmacro APP_UNASSOCIATE "${APPLICATION_PLACEHOLDER_SUFFIX}" "${APPLICATION_PLACEHOLDER_FILECLASS}" !insertmacro APP_UNASSOCIATE "${APPLICATION_VIRTUALFILE_SUFFIX}" "${APPLICATION_VIRTUALFILE_FILECLASS}"
;Shell extension ;Shell extension
!ifdef OPTION_SECTION_SC_SHELL_EXT !ifdef OPTION_SECTION_SC_SHELL_EXT

View File

@ -26,8 +26,8 @@
#cmakedefine APPLICATION_WIZARD_HEADER_BACKGROUND_COLOR "@APPLICATION_WIZARD_HEADER_BACKGROUND_COLOR@" #cmakedefine APPLICATION_WIZARD_HEADER_BACKGROUND_COLOR "@APPLICATION_WIZARD_HEADER_BACKGROUND_COLOR@"
#cmakedefine APPLICATION_WIZARD_HEADER_TITLE_COLOR "@APPLICATION_WIZARD_HEADER_TITLE_COLOR@" #cmakedefine APPLICATION_WIZARD_HEADER_TITLE_COLOR "@APPLICATION_WIZARD_HEADER_TITLE_COLOR@"
#cmakedefine APPLICATION_WIZARD_USE_CUSTOM_LOGO "@APPLICATION_WIZARD_USE_CUSTOM_LOGO@" #cmakedefine APPLICATION_WIZARD_USE_CUSTOM_LOGO "@APPLICATION_WIZARD_USE_CUSTOM_LOGO@"
#cmakedefine APPLICATION_PLACEHOLDER_SUFFIX "@APPLICATION_PLACEHOLDER_SUFFIX@" #cmakedefine APPLICATION_VIRTUALFILE_SUFFIX "@APPLICATION_VIRTUALFILE_SUFFIX@"
#define APPLICATION_DOTPLACEHOLDER_SUFFIX "." APPLICATION_PLACEHOLDER_SUFFIX #define APPLICATION_DOTVIRTUALFILE_SUFFIX "." APPLICATION_VIRTUALFILE_SUFFIX
#cmakedefine ZLIB_FOUND @ZLIB_FOUND@ #cmakedefine ZLIB_FOUND @ZLIB_FOUND@

View File

@ -136,8 +136,8 @@ enum ItemType {
ItemTypeSoftLink = 1, ItemTypeSoftLink = 1,
ItemTypeDirectory = 2, ItemTypeDirectory = 2,
ItemTypeSkip = 3, ItemTypeSkip = 3,
ItemTypePlaceholder = 4, ItemTypeVirtualFile = 4,
ItemTypePlaceholderDownload = 5 ItemTypeVirtualFileDownload = 5
}; };

View File

@ -208,14 +208,14 @@ struct OCSYNC_EXPORT csync_s {
bool upload_conflict_files = false; bool upload_conflict_files = false;
/** /**
* Whether new remote files should start out as placeholders. * Whether new remote files should start out as virtual.
*/ */
bool new_files_are_placeholders = false; bool new_files_are_virtual = false;
/** /**
* The suffix to use for placeholder files. * The suffix to use for virtual files.
*/ */
QByteArray placeholder_suffix; QByteArray virtual_file_suffix;
csync_s(const char *localUri, OCC::SyncJournalDb *statedb); csync_s(const char *localUri, OCC::SyncJournalDb *statedb);
~csync_s(); ~csync_s();

View File

@ -132,25 +132,25 @@ static void _csync_merge_algorithm_visitor(csync_file_stat_t *cur, CSYNC * ctx)
/* If it is ignored, other->instruction will be IGNORE so this one will also be ignored */ /* If it is ignored, other->instruction will be IGNORE so this one will also be ignored */
} }
// If the user adds a file locally check whether a placeholder for that name exists. // If the user adds a file locally check whether a virtual file for that name exists.
// If so, go to "potential conflict" mode by switching the remote entry to be a // If so, go to "potential conflict" mode by switching the remote entry to be a
// real file. // real file.
if (!other if (!other
&& ctx->current == LOCAL_REPLICA && ctx->current == LOCAL_REPLICA
&& cur->instruction == CSYNC_INSTRUCTION_NEW && cur->instruction == CSYNC_INSTRUCTION_NEW
&& cur->type != ItemTypePlaceholder) { && cur->type != ItemTypeVirtualFile) {
// Check if we have a placeholder entry in the remote tree // Check if we have a virtual file entry in the remote tree
auto placeholderPath = cur->path; auto virtualFilePath = cur->path;
placeholderPath.append(ctx->placeholder_suffix); virtualFilePath.append(ctx->virtual_file_suffix);
other = other_tree->findFile(placeholderPath); other = other_tree->findFile(virtualFilePath);
if (!other) { if (!other) {
/* Check the renamed path as well. */ /* Check the renamed path as well. */
other = other_tree->findFile(csync_rename_adjust_parent_path(ctx, placeholderPath)); other = other_tree->findFile(csync_rename_adjust_parent_path(ctx, virtualFilePath));
} }
if (other && other->type == ItemTypePlaceholder) { if (other && other->type == ItemTypeVirtualFile) {
qCInfo(lcReconcile) << "Found placeholder for local" << cur->path << "in remote tree"; qCInfo(lcReconcile) << "Found virtual file for local" << cur->path << "in remote tree";
other->path = cur->path; other->path = cur->path;
other->type = ItemTypePlaceholderDownload; other->type = ItemTypeVirtualFileDownload;
other->instruction = CSYNC_INSTRUCTION_EVAL; other->instruction = CSYNC_INSTRUCTION_EVAL;
} else { } else {
other = nullptr; other = nullptr;
@ -176,12 +176,12 @@ static void _csync_merge_algorithm_visitor(csync_file_stat_t *cur, CSYNC * ctx)
cur->instruction = CSYNC_INSTRUCTION_NEW; cur->instruction = CSYNC_INSTRUCTION_NEW;
break; break;
} }
/* If the local placeholder is gone it should be reestablished. /* If the local virtual file is gone, it should be reestablished.
* Unless the base file is seen in the local tree now. */ * Unless the base file is seen in the local tree now. */
if (cur->type == ItemTypePlaceholder if (cur->type == ItemTypeVirtualFile
&& ctx->current == REMOTE_REPLICA && ctx->current == REMOTE_REPLICA
&& cur->path.endsWith(ctx->placeholder_suffix) && cur->path.endsWith(ctx->virtual_file_suffix)
&& !other_tree->findFile(cur->path.left(cur->path.size() - ctx->placeholder_suffix.size()))) { && !other_tree->findFile(cur->path.left(cur->path.size() - ctx->virtual_file_suffix.size()))) {
cur->instruction = CSYNC_INSTRUCTION_NEW; cur->instruction = CSYNC_INSTRUCTION_NEW;
break; break;
} }
@ -455,13 +455,13 @@ static void _csync_merge_algorithm_visitor(csync_file_stat_t *cur, CSYNC * ctx)
cur->instruction = CSYNC_INSTRUCTION_NEW; cur->instruction = CSYNC_INSTRUCTION_NEW;
break; break;
case CSYNC_INSTRUCTION_NONE: case CSYNC_INSTRUCTION_NONE:
// NONE/NONE on placeholders might become a REMOVE if the base file // NONE/NONE on virtual files might become a REMOVE if the base file
// is found in the local tree. // is found in the local tree.
if (cur->type == ItemTypePlaceholder if (cur->type == ItemTypeVirtualFile
&& other->instruction == CSYNC_INSTRUCTION_NONE && other->instruction == CSYNC_INSTRUCTION_NONE
&& ctx->current == LOCAL_REPLICA && ctx->current == LOCAL_REPLICA
&& cur->path.endsWith(ctx->placeholder_suffix) && cur->path.endsWith(ctx->virtual_file_suffix)
&& ctx->local.files.findFile(cur->path.left(cur->path.size() - ctx->placeholder_suffix.size()))) { && ctx->local.files.findFile(cur->path.left(cur->path.size() - ctx->virtual_file_suffix.size()))) {
cur->instruction = CSYNC_INSTRUCTION_REMOVE; cur->instruction = CSYNC_INSTRUCTION_REMOVE;
} }
break; break;

View File

@ -201,17 +201,17 @@ static int _csync_detect_update(CSYNC *ctx, std::unique_ptr<csync_file_stat_t> f
} }
} }
// The db entry might be for a placeholder, so look for that on the // The db entry might be for a virtual file, so look for that on the
// remote side. If we find one, change the current fs to look like a // remote side. If we find one, change the current fs to look like a
// placeholder too, because that's what one would see if the remote // virtual file too, because that's what one would see if the remote
// db was filled from the database. // db was filled from the database.
if (ctx->current == REMOTE_REPLICA && !base.isValid() && fs->type == ItemTypeFile) { if (ctx->current == REMOTE_REPLICA && !base.isValid() && fs->type == ItemTypeFile) {
auto placeholderPath = fs->path; auto virtualFilePath = fs->path;
placeholderPath.append(ctx->placeholder_suffix); virtualFilePath.append(ctx->virtual_file_suffix);
ctx->statedb->getFileRecord(placeholderPath, &base); ctx->statedb->getFileRecord(virtualFilePath, &base);
if (base.isValid() && base._type == ItemTypePlaceholder) { if (base.isValid() && base._type == ItemTypeVirtualFile) {
fs->type = ItemTypePlaceholder; fs->type = ItemTypeVirtualFile;
fs->path = placeholderPath; fs->path = virtualFilePath;
} else { } else {
base = OCC::SyncJournalFileRecord(); base = OCC::SyncJournalFileRecord();
} }
@ -238,19 +238,19 @@ static int _csync_detect_update(CSYNC *ctx, std::unique_ptr<csync_file_stat_t> f
fs->type, base._type, fs->type, base._type,
base._serverHasIgnoredFiles, base._e2eMangledName.constData()); base._serverHasIgnoredFiles, base._e2eMangledName.constData());
// If the db suggests a placeholder should be downloaded, // If the db suggests a virtual file should be downloaded,
// treat the file as new on the remote. // treat the file as new on the remote.
if (ctx->current == REMOTE_REPLICA && base._type == ItemTypePlaceholderDownload) { if (ctx->current == REMOTE_REPLICA && base._type == ItemTypeVirtualFileDownload) {
fs->instruction = CSYNC_INSTRUCTION_NEW; fs->instruction = CSYNC_INSTRUCTION_NEW;
fs->type = ItemTypePlaceholderDownload; fs->type = ItemTypeVirtualFileDownload;
goto out; goto out;
} }
// If what the db thinks is a placeholder is actually a file/dir, // If what the db thinks is a virtual file is actually a file/dir,
// treat it as new locally. // treat it as new locally.
if (ctx->current == LOCAL_REPLICA if (ctx->current == LOCAL_REPLICA
&& (base._type == ItemTypePlaceholder || base._type == ItemTypePlaceholderDownload) && (base._type == ItemTypeVirtualFile || base._type == ItemTypeVirtualFileDownload)
&& fs->type != ItemTypePlaceholder) { && fs->type != ItemTypeVirtualFile) {
fs->instruction = CSYNC_INSTRUCTION_EVAL; fs->instruction = CSYNC_INSTRUCTION_EVAL;
goto out; goto out;
} }
@ -258,8 +258,8 @@ static int _csync_detect_update(CSYNC *ctx, std::unique_ptr<csync_file_stat_t> f
if (ctx->current == REMOTE_REPLICA && fs->etag != base._etag) { if (ctx->current == REMOTE_REPLICA && fs->etag != base._etag) {
fs->instruction = CSYNC_INSTRUCTION_EVAL; fs->instruction = CSYNC_INSTRUCTION_EVAL;
if (fs->type == ItemTypePlaceholder) { if (fs->type == ItemTypeVirtualFile) {
// If the local thing is a placeholder, we just update the metadata // If the local thing is a virtual file, we just update the metadata
fs->instruction = CSYNC_INSTRUCTION_UPDATE_METADATA; fs->instruction = CSYNC_INSTRUCTION_UPDATE_METADATA;
} else if (base._type != fs->type) { } else if (base._type != fs->type) {
// Preserve the EVAL flag later on if the type has changed. // Preserve the EVAL flag later on if the type has changed.
@ -385,10 +385,10 @@ static int _csync_detect_update(CSYNC *ctx, std::unique_ptr<csync_file_stat_t> f
if (!base.isValid()) if (!base.isValid())
return; return;
if (base._type == ItemTypePlaceholderDownload) { if (base._type == ItemTypeVirtualFileDownload) {
// Remote rename of a placeholder file we have locally scheduled // Remote rename of a virtual file we have locally scheduled
// for download. We just consider this NEW but mark it for download. // for download. We just consider this NEW but mark it for download.
fs->type = ItemTypePlaceholderDownload; fs->type = ItemTypeVirtualFileDownload;
done = true; done = true;
return; return;
} }
@ -397,7 +397,7 @@ static int _csync_detect_update(CSYNC *ctx, std::unique_ptr<csync_file_stat_t> f
// Since we don't do the same checks again in reconcile, we can't // Since we don't do the same checks again in reconcile, we can't
// just skip the candidate, but have to give up completely. // just skip the candidate, but have to give up completely.
if (base._type != fs->type if (base._type != fs->type
&& base._type != ItemTypePlaceholder) { && base._type != ItemTypeVirtualFile) {
qCWarning(lcUpdate, "file types different, not a rename"); qCWarning(lcUpdate, "file types different, not a rename");
done = true; done = true;
return; return;
@ -411,10 +411,10 @@ static int _csync_detect_update(CSYNC *ctx, std::unique_ptr<csync_file_stat_t> f
// Now we know there is a sane rename candidate. // Now we know there is a sane rename candidate.
// Rename of a placeholder // Rename of a virtual file
if (base._type == ItemTypePlaceholder && fs->type == ItemTypeFile) { if (base._type == ItemTypeVirtualFile && fs->type == ItemTypeFile) {
fs->type = ItemTypePlaceholder; fs->type = ItemTypeVirtualFile;
fs->path.append(ctx->placeholder_suffix); fs->path.append(ctx->virtual_file_suffix);
} }
// Record directory renames // Record directory renames
@ -457,12 +457,12 @@ static int _csync_detect_update(CSYNC *ctx, std::unique_ptr<csync_file_stat_t> f
} }
} }
// Turn new remote files into placeholders if the option is enabled. // Turn new remote files into virtual files if the option is enabled.
if (ctx->new_files_are_placeholders if (ctx->new_files_are_virtual
&& fs->instruction == CSYNC_INSTRUCTION_NEW && fs->instruction == CSYNC_INSTRUCTION_NEW
&& fs->type == ItemTypeFile) { && fs->type == ItemTypeFile) {
fs->type = ItemTypePlaceholder; fs->type = ItemTypeVirtualFile;
fs->path.append(ctx->placeholder_suffix); fs->path.append(ctx->virtual_file_suffix);
} }
goto out; goto out;
@ -785,15 +785,15 @@ int csync_ftw(CSYNC *ctx, const char *uri, csync_walker_fn fn,
fullpath = QByteArray() % uri % '/' % filename; fullpath = QByteArray() % uri % '/' % filename;
} }
// When encountering placeholder files, read the relevant // When encountering virtual files, read the relevant
// entry from the db instead. // entry from the db instead.
if (ctx->current == LOCAL_REPLICA if (ctx->current == LOCAL_REPLICA
&& dirent->type == ItemTypeFile && dirent->type == ItemTypeFile
&& filename.endsWith(ctx->placeholder_suffix)) { && filename.endsWith(ctx->virtual_file_suffix)) {
QByteArray db_uri = fullpath.mid(strlen(ctx->local.uri) + 1); QByteArray db_uri = fullpath.mid(strlen(ctx->local.uri) + 1);
if( ! fill_tree_from_db(ctx, db_uri.constData(), true) ) { if( ! fill_tree_from_db(ctx, db_uri.constData(), true) ) {
qCWarning(lcUpdate) << "Placeholder without db entry for" << filename; qCWarning(lcUpdate) << "Virtual file without db entry for" << filename;
QFile::remove(fullpath); QFile::remove(fullpath);
} }

View File

@ -497,7 +497,7 @@ void AccountSettings::slotFolderWizardAccepted()
folderWizard->field(QLatin1String("sourceFolder")).toString()); folderWizard->field(QLatin1String("sourceFolder")).toString());
definition.targetPath = FolderDefinition::prepareTargetPath( definition.targetPath = FolderDefinition::prepareTargetPath(
folderWizard->property("targetPath").toString()); folderWizard->property("targetPath").toString());
definition.usePlaceholders = folderWizard->property("usePlaceholders").toBool(); definition.useVirtualFiles = folderWizard->property("useVirtualFiles").toBool();
{ {
QDir dir(definition.localPath); QDir dir(definition.localPath);

View File

@ -500,9 +500,9 @@ void Application::parseOptions(const QStringList &options)
_backgroundMode = true; _backgroundMode = true;
} else if (option == QLatin1String("--version") || option == QLatin1String("-v")) { } else if (option == QLatin1String("--version") || option == QLatin1String("-v")) {
_versionOnly = true; _versionOnly = true;
} else if (option.endsWith(QStringLiteral(APPLICATION_DOTPLACEHOLDER_SUFFIX))) { } else if (option.endsWith(QStringLiteral(APPLICATION_DOTVIRTUALFILE_SUFFIX))) {
// placeholder file, open it after the Folder were created (if the app is not terminated) // virtual file, open it after the Folder were created (if the app is not terminated)
QTimer::singleShot(0, this, [this, option] { openPlaceholder(option); }); QTimer::singleShot(0, this, [this, option] { openVirtualFile(option); });
} else { } else {
showHint("Unrecognized option '" + option.toStdString() + "'"); showHint("Unrecognized option '" + option.toStdString() + "'");
} }
@ -678,10 +678,10 @@ void Application::slotGuiIsShowingSettings()
emit isShowingSettingsDialog(); emit isShowingSettingsDialog();
} }
void Application::openPlaceholder(const QString &filename) void Application::openVirtualFile(const QString &filename)
{ {
QString placeholderExt = QStringLiteral(APPLICATION_DOTPLACEHOLDER_SUFFIX); QString virtualFileExt = QStringLiteral(APPLICATION_DOTVIRTUALFILE_SUFFIX);
if (!filename.endsWith(placeholderExt)) { if (!filename.endsWith(virtualFileExt)) {
qWarning(lcApplication) << "Can only handle file ending in .owncloud. Unable to open" << filename; qWarning(lcApplication) << "Can only handle file ending in .owncloud. Unable to open" << filename;
return; return;
} }
@ -692,8 +692,8 @@ void Application::openPlaceholder(const QString &filename)
return; return;
} }
QString relativePath = QDir::cleanPath(filename).mid(folder->cleanPath().length() + 1); QString relativePath = QDir::cleanPath(filename).mid(folder->cleanPath().length() + 1);
folder->downloadPlaceholder(relativePath); folder->downloadVirtualFile(relativePath);
QString normalName = filename.left(filename.size() - placeholderExt.size()); QString normalName = filename.left(filename.size() - virtualFileExt.size());
auto con = QSharedPointer<QMetaObject::Connection>::create(); auto con = QSharedPointer<QMetaObject::Connection>::create();
*con = QObject::connect(folder, &Folder::syncFinished, [con, normalName] { *con = QObject::connect(folder, &Folder::syncFinished, [con, normalName] {
QObject::disconnect(*con); QObject::disconnect(*con);
@ -709,9 +709,9 @@ bool Application::event(QEvent *event)
if (event->type() == QEvent::FileOpen) { if (event->type() == QEvent::FileOpen) {
QFileOpenEvent *openEvent = static_cast<QFileOpenEvent *>(event); QFileOpenEvent *openEvent = static_cast<QFileOpenEvent *>(event);
qCDebug(lcApplication) << "QFileOpenEvent" << openEvent->file(); qCDebug(lcApplication) << "QFileOpenEvent" << openEvent->file();
// placeholder file, open it after the Folder were created (if the app is not terminated) // virtual file, open it after the Folder were created (if the app is not terminated)
QString fn = openEvent->file(); QString fn = openEvent->file();
QTimer::singleShot(0, this, [this, fn] { openPlaceholder(fn); }); QTimer::singleShot(0, this, [this, fn] { openVirtualFile(fn); });
} }
#endif #endif
return SharedTools::QtSingleApplication::event(event); return SharedTools::QtSingleApplication::event(event);

View File

@ -74,10 +74,10 @@ public slots:
void slotownCloudWizardDone(int); void slotownCloudWizardDone(int);
void slotCrash(); void slotCrash();
/** /**
* Will download a placeholder file, and open the result. * Will download a virtual file, and open the result.
* The argument is the filename of the placeholder file (including the extension) * The argument is the filename of the virtual file (including the extension)
*/ */
void openPlaceholder(const QString &filename); void openVirtualFile(const QString &filename);
protected: protected:
void parseOptions(const QStringList &); void parseOptions(const QStringList &);

View File

@ -520,9 +520,9 @@ void Folder::slotWatchedPathChanged(const QString &path)
scheduleThisFolderSoon(); scheduleThisFolderSoon();
} }
void Folder::downloadPlaceholder(const QString &_relativepath) void Folder::downloadVirtualFile(const QString &_relativepath)
{ {
qCInfo(lcFolder) << "Download placeholder: " << _relativepath; qCInfo(lcFolder) << "Download virtual file: " << _relativepath;
auto relativepath = _relativepath.toUtf8(); auto relativepath = _relativepath.toUtf8();
// Set in the database that we should download the file // Set in the database that we should download the file
@ -530,7 +530,7 @@ void Folder::downloadPlaceholder(const QString &_relativepath)
_journal.getFileRecord(relativepath, &record); _journal.getFileRecord(relativepath, &record);
if (!record.isValid()) if (!record.isValid())
return; return;
record._type = ItemTypePlaceholderDownload; record._type = ItemTypeVirtualFileDownload;
_journal.setFileRecord(record); _journal.setFileRecord(record);
// Make sure we go over that file during the discovery // Make sure we go over that file during the discovery
@ -554,9 +554,10 @@ void Folder::saveToSettings() const
return other != this && other->cleanPath() == this->cleanPath(); return other != this && other->cleanPath() == this->cleanPath();
}); });
if (_definition.usePlaceholders) { if (_definition.useVirtualFiles) {
// If placeholders are enabled, save the folder to a group // If virtual files are enabled, save the folder to a group
// that will not be read by older (<2.5.0) clients. // that will not be read by older (<2.5.0) clients.
// The name is from when virtual files were called placeholders.
settingsGroup = QStringLiteral("FoldersWithPlaceholders"); settingsGroup = QStringLiteral("FoldersWithPlaceholders");
} else if (_saveBackwardsCompatible || oneAccountOnly) { } else if (_saveBackwardsCompatible || oneAccountOnly) {
// The folder is saved to backwards-compatible "Folders" // The folder is saved to backwards-compatible "Folders"
@ -720,8 +721,8 @@ void Folder::setSyncOptions()
opt._newBigFolderSizeLimit = newFolderLimit.first ? newFolderLimit.second * 1000LL * 1000LL : -1; // convert from MB to B opt._newBigFolderSizeLimit = newFolderLimit.first ? newFolderLimit.second * 1000LL * 1000LL : -1; // convert from MB to B
opt._confirmExternalStorage = cfgFile.confirmExternalStorage(); opt._confirmExternalStorage = cfgFile.confirmExternalStorage();
opt._moveFilesToTrash = cfgFile.moveToTrash(); opt._moveFilesToTrash = cfgFile.moveToTrash();
opt._newFilesArePlaceholders = _definition.usePlaceholders; opt._newFilesAreVirtual = _definition.useVirtualFiles;
opt._placeholderSuffix = QStringLiteral(APPLICATION_DOTPLACEHOLDER_SUFFIX); opt._virtualFileSuffix = QStringLiteral(APPLICATION_DOTVIRTUALFILE_SUFFIX);
QByteArray chunkSizeEnv = qgetenv("OWNCLOUD_CHUNK_SIZE"); QByteArray chunkSizeEnv = qgetenv("OWNCLOUD_CHUNK_SIZE");
if (!chunkSizeEnv.isEmpty()) { if (!chunkSizeEnv.isEmpty()) {
@ -1125,7 +1126,7 @@ void FolderDefinition::save(QSettings &settings, const FolderDefinition &folder)
settings.setValue(QLatin1String("targetPath"), folder.targetPath); settings.setValue(QLatin1String("targetPath"), folder.targetPath);
settings.setValue(QLatin1String("paused"), folder.paused); settings.setValue(QLatin1String("paused"), folder.paused);
settings.setValue(QLatin1String("ignoreHiddenFiles"), folder.ignoreHiddenFiles); settings.setValue(QLatin1String("ignoreHiddenFiles"), folder.ignoreHiddenFiles);
settings.setValue(QLatin1String("usePlaceholders"), folder.usePlaceholders); settings.setValue(QLatin1String("usePlaceholders"), folder.useVirtualFiles);
// Happens only on Windows when the explorer integration is enabled. // Happens only on Windows when the explorer integration is enabled.
if (!folder.navigationPaneClsid.isNull()) if (!folder.navigationPaneClsid.isNull())
@ -1146,7 +1147,7 @@ bool FolderDefinition::load(QSettings &settings, const QString &alias,
folder->paused = settings.value(QLatin1String("paused")).toBool(); folder->paused = settings.value(QLatin1String("paused")).toBool();
folder->ignoreHiddenFiles = settings.value(QLatin1String("ignoreHiddenFiles"), QVariant(true)).toBool(); folder->ignoreHiddenFiles = settings.value(QLatin1String("ignoreHiddenFiles"), QVariant(true)).toBool();
folder->navigationPaneClsid = settings.value(QLatin1String("navigationPaneClsid")).toUuid(); folder->navigationPaneClsid = settings.value(QLatin1String("navigationPaneClsid")).toUuid();
folder->usePlaceholders = settings.value(QLatin1String("usePlaceholders")).toBool(); folder->useVirtualFiles = settings.value(QLatin1String("usePlaceholders")).toBool();
settings.endGroup(); settings.endGroup();
// Old settings can contain paths with native separators. In the rest of the // Old settings can contain paths with native separators. In the rest of the

View File

@ -60,8 +60,8 @@ public:
bool paused = false; bool paused = false;
/// whether the folder syncs hidden files /// whether the folder syncs hidden files
bool ignoreHiddenFiles = false; bool ignoreHiddenFiles = false;
/// New files are downloaded as placeholders /// New files are downloaded as virtual files
bool usePlaceholders = false; bool useVirtualFiles = false;
/// The CLSID where this folder appears in registry for the Explorer navigation pane entry. /// The CLSID where this folder appears in registry for the Explorer navigation pane entry.
QUuid navigationPaneClsid; QUuid navigationPaneClsid;
@ -280,10 +280,10 @@ public slots:
void slotWatchedPathChanged(const QString &path); void slotWatchedPathChanged(const QString &path);
/** /**
* Mark a placeholder as being ready for download, and start a sync. * Mark a virtual file as being ready for download, and start a sync.
* relativePath is the patch to the placeholder file (includeing the extension) * relativePath is the patch to the file (including the extension)
*/ */
void downloadPlaceholder(const QString &relativepath); void downloadVirtualFile(const QString &relativepath);
private slots: private slots:
void slotSyncStarted(); void slotSyncStarted();

View File

@ -495,9 +495,9 @@ FolderWizardSelectiveSync::FolderWizardSelectiveSync(const AccountPtr &account)
layout->addWidget(_selectiveSync); layout->addWidget(_selectiveSync);
if (ConfigFile().showExperimentalOptions()) { if (ConfigFile().showExperimentalOptions()) {
_placeholderCheckBox = new QCheckBox(tr("Use virtual files instead of downloading content immediately (experimental)")); _virtualFilesCheckBox = new QCheckBox(tr("Use virtual files instead of downloading content immediately (experimental)"));
connect(_placeholderCheckBox, &QCheckBox::clicked, this, &FolderWizardSelectiveSync::placeholderCheckboxClicked); connect(_virtualFilesCheckBox, &QCheckBox::clicked, this, &FolderWizardSelectiveSync::virtualFilesCheckboxClicked);
layout->addWidget(_placeholderCheckBox); layout->addWidget(_virtualFilesCheckBox);
} }
} }
@ -524,7 +524,7 @@ void FolderWizardSelectiveSync::initializePage()
bool FolderWizardSelectiveSync::validatePage() bool FolderWizardSelectiveSync::validatePage()
{ {
wizard()->setProperty("selectiveSyncBlackList", QVariant(_selectiveSync->createBlackList())); wizard()->setProperty("selectiveSyncBlackList", QVariant(_selectiveSync->createBlackList()));
wizard()->setProperty("usePlaceholders", QVariant(_placeholderCheckBox && _placeholderCheckBox->isChecked())); wizard()->setProperty("useVirtualFiles", QVariant(_virtualFilesCheckBox && _virtualFilesCheckBox->isChecked()));
return true; return true;
} }
@ -538,14 +538,14 @@ void FolderWizardSelectiveSync::cleanupPage()
QWizardPage::cleanupPage(); QWizardPage::cleanupPage();
} }
void FolderWizardSelectiveSync::placeholderCheckboxClicked() void FolderWizardSelectiveSync::virtualFilesCheckboxClicked()
{ {
// The click has already had an effect on the box, so if it's // The click has already had an effect on the box, so if it's
// checked it was newly activated. // checked it was newly activated.
if (_placeholderCheckBox->isChecked()) { if (_virtualFilesCheckBox->isChecked()) {
OwncloudWizard::askExperimentalPlaceholderFeature([this](bool enable) { OwncloudWizard::askExperimentalVirtualFilesFeature([this](bool enable) {
if (!enable) if (!enable)
_placeholderCheckBox->setChecked(false); _virtualFilesCheckBox->setChecked(false);
}); });
} }
} }

View File

@ -131,11 +131,11 @@ public:
void cleanupPage() override; void cleanupPage() override;
private slots: private slots:
void placeholderCheckboxClicked(); void virtualFilesCheckboxClicked();
private: private:
SelectiveSyncWidget *_selectiveSync; SelectiveSyncWidget *_selectiveSync;
QCheckBox *_placeholderCheckBox = nullptr; QCheckBox *_virtualFilesCheckBox = nullptr;
}; };
/** /**

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info"> <mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="application/x-@APPLICATION_EXECUTABLE@"> <mime-type type="application/x-@APPLICATION_EXECUTABLE@">
<comment>@APPLICATION_NAME@ placeholders</comment> <comment>@APPLICATION_NAME@ virtual files</comment>
<glob pattern="*.@APPLICATION_PLACEHOLDER_SUFFIX@"/> <glob pattern="*.@APPLICATION_VIRTUALFILE_SUFFIX@"/>
</mime-type> </mime-type>
</mime-info> </mime-info>

View File

@ -633,7 +633,7 @@ void OwncloudSetupWizard::slotAssistantFinished(int result)
folderDefinition.localPath = localFolder; folderDefinition.localPath = localFolder;
folderDefinition.targetPath = FolderDefinition::prepareTargetPath(_remoteFolder); folderDefinition.targetPath = FolderDefinition::prepareTargetPath(_remoteFolder);
folderDefinition.ignoreHiddenFiles = folderMan->ignoreHiddenFiles(); folderDefinition.ignoreHiddenFiles = folderMan->ignoreHiddenFiles();
folderDefinition.usePlaceholders = _ocWizard->usePlaceholderSync(); folderDefinition.useVirtualFiles = _ocWizard->useVirtualFileSync();
if (folderMan->navigationPaneHelper().showInExplorerNavigationPane()) if (folderMan->navigationPaneHelper().showInExplorerNavigationPane())
folderDefinition.navigationPaneClsid = QUuid::createUuid(); folderDefinition.navigationPaneClsid = QUuid::createUuid();

View File

@ -686,18 +686,18 @@ void SocketApi::command_OPEN_PRIVATE_LINK(const QString &localFile, SocketListen
fetchPrivateLinkUrlHelper(localFile, &SocketApi::openPrivateLink); fetchPrivateLinkUrlHelper(localFile, &SocketApi::openPrivateLink);
} }
void SocketApi::command_DOWNLOAD_PLACEHOLDER(const QString &filesArg, SocketListener *) void SocketApi::command_DOWNLOAD_VIRTUAL_FILE(const QString &filesArg, SocketListener *)
{ {
QStringList files = filesArg.split(QLatin1Char('\x1e')); // Record Separator QStringList files = filesArg.split(QLatin1Char('\x1e')); // Record Separator
auto placeholderSuffix = QStringLiteral(APPLICATION_DOTPLACEHOLDER_SUFFIX); auto suffix = QStringLiteral(APPLICATION_DOTVIRTUALFILE_SUFFIX);
for (const auto &file : files) { for (const auto &file : files) {
if (!file.endsWith(placeholderSuffix)) if (!file.endsWith(suffix))
continue; continue;
auto folder = FolderMan::instance()->folderForPath(file); auto folder = FolderMan::instance()->folderForPath(file);
if (folder) { if (folder) {
QString relativePath = QDir::cleanPath(file).mid(folder->cleanPath().length() + 1); QString relativePath = QDir::cleanPath(file).mid(folder->cleanPath().length() + 1);
folder->downloadPlaceholder(relativePath); folder->downloadVirtualFile(relativePath);
} }
} }
} }
@ -972,16 +972,16 @@ void SocketApi::command_GET_MENU_ITEMS(const QString &argument, OCC::SocketListe
} }
} }
// Placeholder download action // Virtual file download action
if (syncFolder) { if (syncFolder) {
auto placeholderSuffix = QStringLiteral(APPLICATION_DOTPLACEHOLDER_SUFFIX); auto virtualFileSuffix = QStringLiteral(APPLICATION_DOTVIRTUALFILE_SUFFIX);
bool hasPlaceholderFile = false; bool hasVirtualFile = false;
for (const auto &file : files) { for (const auto &file : files) {
if (file.endsWith(placeholderSuffix)) if (file.endsWith(virtualFileSuffix))
hasPlaceholderFile = true; hasVirtualFile = true;
} }
if (hasPlaceholderFile) if (hasVirtualFile)
listener->sendMessage(QLatin1String("MENU_ITEM:DOWNLOAD_PLACEHOLDER::") + tr("Download file(s)", "", files.size())); listener->sendMessage(QLatin1String("MENU_ITEM:DOWNLOAD_VIRTUAL_FILE::") + tr("Download file(s)", "", files.size()));
} }
listener->sendMessage(QString("GET_MENU_ITEMS:END")); listener->sendMessage(QString("GET_MENU_ITEMS:END"));

View File

@ -106,7 +106,7 @@ private:
Q_INVOKABLE void command_COPY_PRIVATE_LINK(const QString &localFile, SocketListener *listener); Q_INVOKABLE void command_COPY_PRIVATE_LINK(const QString &localFile, SocketListener *listener);
Q_INVOKABLE void command_EMAIL_PRIVATE_LINK(const QString &localFile, SocketListener *listener); Q_INVOKABLE void command_EMAIL_PRIVATE_LINK(const QString &localFile, SocketListener *listener);
Q_INVOKABLE void command_OPEN_PRIVATE_LINK(const QString &localFile, SocketListener *listener); Q_INVOKABLE void command_OPEN_PRIVATE_LINK(const QString &localFile, SocketListener *listener);
Q_INVOKABLE void command_DOWNLOAD_PLACEHOLDER(const QString &filesArg, SocketListener *listener); Q_INVOKABLE void command_DOWNLOAD_VIRTUAL_FILE(const QString &filesArg, SocketListener *listener);
Q_INVOKABLE void command_RESOLVE_CONFLICT(const QString &localFile, SocketListener *listener); Q_INVOKABLE void command_RESOLVE_CONFLICT(const QString &localFile, SocketListener *listener);
Q_INVOKABLE void command_DELETE_ITEM(const QString &localFile, SocketListener *listener); Q_INVOKABLE void command_DELETE_ITEM(const QString &localFile, SocketListener *listener);
Q_INVOKABLE void command_MOVE_ITEM(const QString &localFile, SocketListener *listener); Q_INVOKABLE void command_MOVE_ITEM(const QString &localFile, SocketListener *listener);

View File

@ -56,7 +56,7 @@ OwncloudAdvancedSetupPage::OwncloudAdvancedSetupPage()
connect(_ui.rSyncEverything, &QAbstractButton::clicked, this, &OwncloudAdvancedSetupPage::slotSyncEverythingClicked); connect(_ui.rSyncEverything, &QAbstractButton::clicked, this, &OwncloudAdvancedSetupPage::slotSyncEverythingClicked);
connect(_ui.rSelectiveSync, &QAbstractButton::clicked, this, &OwncloudAdvancedSetupPage::slotSelectiveSyncClicked); connect(_ui.rSelectiveSync, &QAbstractButton::clicked, this, &OwncloudAdvancedSetupPage::slotSelectiveSyncClicked);
connect(_ui.rPlaceholderSync, &QAbstractButton::clicked, this, &OwncloudAdvancedSetupPage::slotPlaceholderSyncClicked); connect(_ui.rVirtualFileSync, &QAbstractButton::clicked, this, &OwncloudAdvancedSetupPage::slotVirtualFileSyncClicked);
connect(_ui.bSelectiveSync, &QAbstractButton::clicked, this, &OwncloudAdvancedSetupPage::slotSelectiveSyncClicked); connect(_ui.bSelectiveSync, &QAbstractButton::clicked, this, &OwncloudAdvancedSetupPage::slotSelectiveSyncClicked);
QIcon appIcon = theme->applicationIcon(); QIcon appIcon = theme->applicationIcon();
@ -106,8 +106,8 @@ void OwncloudAdvancedSetupPage::initializePage()
// If the layout were wrapped in a widget, the auto-grouping of the // If the layout were wrapped in a widget, the auto-grouping of the
// radio buttons no longer works and there are surprising margins. // radio buttons no longer works and there are surprising margins.
// Just manually hide the button and remove the layout. // Just manually hide the button and remove the layout.
_ui.rPlaceholderSync->hide(); _ui.rVirtualFileSync->hide();
_ui.wSyncStrategy->layout()->removeItem(_ui.lPlaceholderSync); _ui.wSyncStrategy->layout()->removeItem(_ui.lVirtualFileSync);
} }
_checking = false; _checking = false;
@ -241,9 +241,9 @@ QStringList OwncloudAdvancedSetupPage::selectiveSyncBlacklist() const
return _selectiveSyncBlacklist; return _selectiveSyncBlacklist;
} }
bool OwncloudAdvancedSetupPage::usePlaceholderSync() const bool OwncloudAdvancedSetupPage::useVirtualFileSync() const
{ {
return _ui.rPlaceholderSync->isChecked(); return _ui.rVirtualFileSync->isChecked();
} }
bool OwncloudAdvancedSetupPage::isConfirmBigFolderChecked() const bool OwncloudAdvancedSetupPage::isConfirmBigFolderChecked() const
@ -363,15 +363,15 @@ void OwncloudAdvancedSetupPage::slotSelectiveSyncClicked()
} }
} }
void OwncloudAdvancedSetupPage::slotPlaceholderSyncClicked() void OwncloudAdvancedSetupPage::slotVirtualFileSyncClicked()
{ {
OwncloudWizard::askExperimentalPlaceholderFeature([this](bool enable) { OwncloudWizard::askExperimentalVirtualFilesFeature([this](bool enable) {
if (!enable) if (!enable)
return; return;
_ui.lSelectiveSyncSizeLabel->setText(QString()); _ui.lSelectiveSyncSizeLabel->setText(QString());
_selectiveSyncBlacklist.clear(); _selectiveSyncBlacklist.clear();
setRadioChecked(_ui.rPlaceholderSync); setRadioChecked(_ui.rVirtualFileSync);
}); });
} }
@ -422,15 +422,15 @@ void OwncloudAdvancedSetupPage::customizeStyle()
void OwncloudAdvancedSetupPage::setRadioChecked(QRadioButton *radio) void OwncloudAdvancedSetupPage::setRadioChecked(QRadioButton *radio)
{ {
// We don't want clicking the radio buttons to immediately adjust the checked state // We don't want clicking the radio buttons to immediately adjust the checked state
// for selective sync and placeholder sync, so we keep them uncheckable until // for selective sync and virtual file sync, so we keep them uncheckable until
// they should be checked. // they should be checked.
radio->setCheckable(true); radio->setCheckable(true);
radio->setChecked(true); radio->setChecked(true);
if (radio != _ui.rSelectiveSync) if (radio != _ui.rSelectiveSync)
_ui.rSelectiveSync->setCheckable(false); _ui.rSelectiveSync->setCheckable(false);
if (radio != _ui.rPlaceholderSync) if (radio != _ui.rVirtualFileSync)
_ui.rPlaceholderSync->setCheckable(false); _ui.rVirtualFileSync->setCheckable(false);
} }
} // namespace OCC } // namespace OCC

View File

@ -41,7 +41,7 @@ public:
bool validatePage() override; bool validatePage() override;
QString localFolder() const; QString localFolder() const;
QStringList selectiveSyncBlacklist() const; QStringList selectiveSyncBlacklist() const;
bool usePlaceholderSync() const; bool useVirtualFileSync() const;
bool isConfirmBigFolderChecked() const; bool isConfirmBigFolderChecked() const;
void setRemoteFolder(const QString &remoteFolder); void setRemoteFolder(const QString &remoteFolder);
void setMultipleFoldersExist(bool exist); void setMultipleFoldersExist(bool exist);
@ -58,7 +58,7 @@ private slots:
void slotSelectFolder(); void slotSelectFolder();
void slotSyncEverythingClicked(); void slotSyncEverythingClicked();
void slotSelectiveSyncClicked(); void slotSelectiveSyncClicked();
void slotPlaceholderSyncClicked(); void slotVirtualFileSyncClicked();
void slotQuotaRetrieved(const QVariantMap &result); void slotQuotaRetrieved(const QVariantMap &result);
private: private:

View File

@ -228,9 +228,9 @@
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="lPlaceholderSync"> <layout class="QHBoxLayout" name="lVirtualFileSync">
<item> <item>
<widget class="QRadioButton" name="rPlaceholderSync"> <widget class="QRadioButton" name="rVirtualFileSync">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum"> <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch> <horstretch>0</horstretch>

View File

@ -133,9 +133,9 @@ QStringList OwncloudWizard::selectiveSyncBlacklist() const
return _advancedSetupPage->selectiveSyncBlacklist(); return _advancedSetupPage->selectiveSyncBlacklist();
} }
bool OwncloudWizard::usePlaceholderSync() const bool OwncloudWizard::useVirtualFileSync() const
{ {
return _advancedSetupPage->usePlaceholderSync(); return _advancedSetupPage->useVirtualFileSync();
} }
bool OwncloudWizard::isConfirmBigFolderChecked() const bool OwncloudWizard::isConfirmBigFolderChecked() const
@ -326,7 +326,7 @@ void OwncloudWizard::bringToTop()
ownCloudGui::raiseDialog(this); ownCloudGui::raiseDialog(this);
} }
void OwncloudWizard::askExperimentalPlaceholderFeature(const std::function<void(bool enable)> &callback) void OwncloudWizard::askExperimentalVirtualFilesFeature(const std::function<void(bool enable)> &callback)
{ {
auto msgBox = new QMessageBox( auto msgBox = new QMessageBox(
QMessageBox::Warning, QMessageBox::Warning,
@ -337,7 +337,7 @@ void OwncloudWizard::askExperimentalPlaceholderFeature(const std::function<void(
"\n\n" "\n\n"
"This is a new, experimental mode. If you decide to use it, please report any " "This is a new, experimental mode. If you decide to use it, please report any "
"issues that come up.") "issues that come up.")
.arg(APPLICATION_DOTPLACEHOLDER_SUFFIX)); .arg(APPLICATION_DOTVIRTUALFILE_SUFFIX));
msgBox->addButton(tr("Enable experimental mode"), QMessageBox::AcceptRole); msgBox->addButton(tr("Enable experimental mode"), QMessageBox::AcceptRole);
msgBox->addButton(tr("Stay safe"), QMessageBox::RejectRole); msgBox->addButton(tr("Stay safe"), QMessageBox::RejectRole);
connect(msgBox, &QMessageBox::finished, msgBox, [callback, msgBox](int result) { connect(msgBox, &QMessageBox::finished, msgBox, [callback, msgBox](int result) {

View File

@ -67,7 +67,7 @@ public:
QString ocUrl() const; QString ocUrl() const;
QString localFolder() const; QString localFolder() const;
QStringList selectiveSyncBlacklist() const; QStringList selectiveSyncBlacklist() const;
bool usePlaceholderSync() const; bool useVirtualFileSync() const;
bool isConfirmBigFolderChecked() const; bool isConfirmBigFolderChecked() const;
void enableFinishOnResultWidget(bool enable); void enableFinishOnResultWidget(bool enable);
@ -78,11 +78,11 @@ public:
void bringToTop(); void bringToTop();
/** /**
* Shows a dialog explaining the placeholder mode and warning about it * Shows a dialog explaining the virtual files mode and warning about it
* being experimental. Calles the callback with true if enabling was * being experimental. Calles the callback with true if enabling was
* chosen. * chosen.
*/ */
static void askExperimentalPlaceholderFeature(const std::function<void(bool enable)> &callback); static void askExperimentalVirtualFilesFeature(const std::function<void(bool enable)> &callback);
// FIXME: Can those be local variables? // FIXME: Can those be local variables?
// Set from the OwncloudSetupPage, later used from OwncloudHttpCredsPage // Set from the OwncloudSetupPage, later used from OwncloudHttpCredsPage

View File

@ -606,9 +606,9 @@ QString OwncloudPropagator::getFilePath(const QString &tmp_file_name) const
return _localDir + tmp_file_name; return _localDir + tmp_file_name;
} }
QString OwncloudPropagator::addPlaceholderSuffix(const QString &fileName) const QString OwncloudPropagator::addVirtualFileSuffix(const QString &fileName) const
{ {
return fileName + _syncOptions._placeholderSuffix; return fileName + _syncOptions._virtualFileSuffix;
} }
void OwncloudPropagator::scheduleNextJob() void OwncloudPropagator::scheduleNextJob()

View File

@ -453,7 +453,7 @@ public:
/* returns the local file path for the given tmp_file_name */ /* returns the local file path for the given tmp_file_name */
QString getFilePath(const QString &tmp_file_name) const; QString getFilePath(const QString &tmp_file_name) const;
QString addPlaceholderSuffix(const QString &fileName) const; QString addVirtualFileSuffix(const QString &fileName) const;
/** Creates the job for an item. /** Creates the job for an item.
*/ */

View File

@ -387,10 +387,10 @@ void PropagateDownloadFile::startAfterIsEncryptedIsChecked()
{ {
_stopwatch.start(); _stopwatch.start();
// For placeholder files just create the file and be done // For virtual files just create the file and be done
if (_item->_type == ItemTypePlaceholder) { if (_item->_type == ItemTypeVirtualFile) {
auto fn = propagator()->getFilePath(_item->_file); auto fn = propagator()->getFilePath(_item->_file);
qCDebug(lcPropagateDownload) << "creating placeholder file" << fn; qCDebug(lcPropagateDownload) << "creating virtual file" << fn;
QFile file(fn); QFile file(fn);
file.open(QFile::ReadWrite | QFile::Truncate); file.open(QFile::ReadWrite | QFile::Truncate);
file.write(" "); file.write(" ");
@ -399,14 +399,14 @@ void PropagateDownloadFile::startAfterIsEncryptedIsChecked()
return; return;
} }
// If we want to download something that used to be a placeholder, // If we want to download something that used to be a virtual file,
// wipe the placeholder and proceed with a normal download // wipe the virtual file and proceed with a normal download
if (_item->_type == ItemTypePlaceholderDownload) { if (_item->_type == ItemTypeVirtualFileDownload) {
auto placeholder = propagator()->addPlaceholderSuffix(_item->_file); auto virtualFile = propagator()->addVirtualFileSuffix(_item->_file);
auto fn = propagator()->getFilePath(placeholder); auto fn = propagator()->getFilePath(virtualFile);
qCDebug(lcPropagateDownload) << "Downloading file that used to be a placeholder" << fn; qCDebug(lcPropagateDownload) << "Downloading file that used to be a virtual file" << fn;
QFile::remove(fn); QFile::remove(fn);
propagator()->_journal->deleteFileRecord(placeholder); propagator()->_journal->deleteFileRecord(virtualFile);
_item->_type = ItemTypeFile; _item->_type = ItemTypeFile;
} }

View File

@ -621,7 +621,7 @@ int SyncEngine::treewalkFile(csync_file_stat_t *file, csync_file_stat_t *other,
if (remote) { if (remote) {
QString filePath = _localPath + item->_file; QString filePath = _localPath + item->_file;
if (other && other->type != ItemTypePlaceholder && other->type != ItemTypePlaceholderDownload) { if (other && other->type != ItemTypeVirtualFile && other->type != ItemTypeVirtualFileDownload) {
// Even if the mtime is different on the server, we always want to keep the mtime from // 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 // the file system in the DB, this is to avoid spurious upload on the next sync
item->_modtime = other->modtime; item->_modtime = other->modtime;
@ -858,11 +858,11 @@ void SyncEngine::startSync()
return shouldDiscoverLocally(path); return shouldDiscoverLocally(path);
}; };
_csync_ctx->new_files_are_placeholders = _syncOptions._newFilesArePlaceholders; _csync_ctx->new_files_are_virtual = _syncOptions._newFilesAreVirtual;
_csync_ctx->placeholder_suffix = _syncOptions._placeholderSuffix.toUtf8(); _csync_ctx->virtual_file_suffix = _syncOptions._virtualFileSuffix.toUtf8();
if (_csync_ctx->new_files_are_placeholders && _csync_ctx->placeholder_suffix.isEmpty()) { if (_csync_ctx->new_files_are_virtual && _csync_ctx->virtual_file_suffix.isEmpty()) {
csyncError(tr("Using virtual files but placeholder suffix is not set")); csyncError(tr("Using virtual files but suffix is not set"));
finalize(false); finalize(false);
return; return;
} }

View File

@ -36,9 +36,9 @@ struct SyncOptions
/** If remotely deleted files are needed to move to trash */ /** If remotely deleted files are needed to move to trash */
bool _moveFilesToTrash = false; bool _moveFilesToTrash = false;
/** Create a placeholder for new files instead of downloading */ /** Create a virtual file for new files instead of downloading */
bool _newFilesArePlaceholders = false; bool _newFilesAreVirtual = false;
QString _placeholderSuffix = ".owncloud"; QString _virtualFileSuffix = ".owncloud";
/** The initial un-adjusted chunk size in bytes for chunked uploads, both /** 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 * for old and new chunking algorithm, which classifies the item to be chunked

View File

@ -46,7 +46,7 @@ nextcloud_add_test(ExcludedFiles "")
nextcloud_add_test(FileSystem "") nextcloud_add_test(FileSystem "")
nextcloud_add_test(Utility "") nextcloud_add_test(Utility "")
nextcloud_add_test(SyncEngine "syncenginetestutils.h") nextcloud_add_test(SyncEngine "syncenginetestutils.h")
nextcloud_add_test(SyncPlaceholders "syncenginetestutils.h") nextcloud_add_test(SyncVirtualFiles "syncenginetestutils.h")
nextcloud_add_test(SyncMove "syncenginetestutils.h") nextcloud_add_test(SyncMove "syncenginetestutils.h")
nextcloud_add_test(SyncConflict "syncenginetestutils.h") nextcloud_add_test(SyncConflict "syncenginetestutils.h")
nextcloud_add_test(SyncFileStatusTracker "syncenginetestutils.h") nextcloud_add_test(SyncFileStatusTracker "syncenginetestutils.h")

View File

@ -34,12 +34,12 @@ SyncJournalFileRecord dbRecord(FakeFolder &folder, const QString &path)
return record; return record;
} }
class TestSyncPlaceholders : public QObject class TestSyncVirtualFiles : public QObject
{ {
Q_OBJECT Q_OBJECT
private slots: private slots:
void testPlaceholderLifecycle_data() void testVirtualFileLifecycle_data()
{ {
QTest::addColumn<bool>("doLocalDiscovery"); QTest::addColumn<bool>("doLocalDiscovery");
@ -47,13 +47,13 @@ private slots:
QTest::newRow("skip local discovery") << false; QTest::newRow("skip local discovery") << false;
} }
void testPlaceholderLifecycle() void testVirtualFileLifecycle()
{ {
QFETCH(bool, doLocalDiscovery); QFETCH(bool, doLocalDiscovery);
FakeFolder fakeFolder{FileInfo()}; FakeFolder fakeFolder{ FileInfo() };
SyncOptions syncOptions; SyncOptions syncOptions;
syncOptions._newFilesArePlaceholders = true; syncOptions._newFilesAreVirtual = true;
fakeFolder.syncEngine().setSyncOptions(syncOptions); fakeFolder.syncEngine().setSyncOptions(syncOptions);
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItemPtr &))); QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItemPtr &)));
@ -65,7 +65,7 @@ private slots:
}; };
cleanup(); cleanup();
// Create a placeholder for a new remote file // Create a virtual file for a new remote file
fakeFolder.remoteModifier().mkdir("A"); fakeFolder.remoteModifier().mkdir("A");
fakeFolder.remoteModifier().insert("A/a1", 64); fakeFolder.remoteModifier().insert("A/a1", 64);
QVERIFY(fakeFolder.syncOnce()); QVERIFY(fakeFolder.syncOnce());
@ -73,7 +73,7 @@ private slots:
QVERIFY(fakeFolder.currentLocalState().find("A/a1.owncloud")); QVERIFY(fakeFolder.currentLocalState().find("A/a1.owncloud"));
QVERIFY(fakeFolder.currentRemoteState().find("A/a1")); QVERIFY(fakeFolder.currentRemoteState().find("A/a1"));
QVERIFY(itemInstruction(completeSpy, "A/a1.owncloud", CSYNC_INSTRUCTION_NEW)); QVERIFY(itemInstruction(completeSpy, "A/a1.owncloud", CSYNC_INSTRUCTION_NEW));
QCOMPARE(dbRecord(fakeFolder, "A/a1.owncloud")._type, ItemTypePlaceholder); QCOMPARE(dbRecord(fakeFolder, "A/a1.owncloud")._type, ItemTypeVirtualFile);
cleanup(); cleanup();
// Another sync doesn't actually lead to changes // Another sync doesn't actually lead to changes
@ -81,7 +81,7 @@ private slots:
QVERIFY(!fakeFolder.currentLocalState().find("A/a1")); QVERIFY(!fakeFolder.currentLocalState().find("A/a1"));
QVERIFY(fakeFolder.currentLocalState().find("A/a1.owncloud")); QVERIFY(fakeFolder.currentLocalState().find("A/a1.owncloud"));
QVERIFY(fakeFolder.currentRemoteState().find("A/a1")); QVERIFY(fakeFolder.currentRemoteState().find("A/a1"));
QCOMPARE(dbRecord(fakeFolder, "A/a1.owncloud")._type, ItemTypePlaceholder); QCOMPARE(dbRecord(fakeFolder, "A/a1.owncloud")._type, ItemTypeVirtualFile);
QVERIFY(completeSpy.isEmpty()); QVERIFY(completeSpy.isEmpty());
cleanup(); cleanup();
@ -91,7 +91,7 @@ private slots:
QVERIFY(!fakeFolder.currentLocalState().find("A/a1")); QVERIFY(!fakeFolder.currentLocalState().find("A/a1"));
QVERIFY(fakeFolder.currentLocalState().find("A/a1.owncloud")); QVERIFY(fakeFolder.currentLocalState().find("A/a1.owncloud"));
QVERIFY(fakeFolder.currentRemoteState().find("A/a1")); QVERIFY(fakeFolder.currentRemoteState().find("A/a1"));
QCOMPARE(dbRecord(fakeFolder, "A/a1.owncloud")._type, ItemTypePlaceholder); QCOMPARE(dbRecord(fakeFolder, "A/a1.owncloud")._type, ItemTypeVirtualFile);
QVERIFY(completeSpy.isEmpty()); QVERIFY(completeSpy.isEmpty());
cleanup(); cleanup();
@ -102,11 +102,11 @@ private slots:
QVERIFY(fakeFolder.currentLocalState().find("A/a1.owncloud")); QVERIFY(fakeFolder.currentLocalState().find("A/a1.owncloud"));
QVERIFY(fakeFolder.currentRemoteState().find("A/a1")); QVERIFY(fakeFolder.currentRemoteState().find("A/a1"));
QVERIFY(itemInstruction(completeSpy, "A/a1.owncloud", CSYNC_INSTRUCTION_UPDATE_METADATA)); QVERIFY(itemInstruction(completeSpy, "A/a1.owncloud", CSYNC_INSTRUCTION_UPDATE_METADATA));
QCOMPARE(dbRecord(fakeFolder, "A/a1.owncloud")._type, ItemTypePlaceholder); QCOMPARE(dbRecord(fakeFolder, "A/a1.owncloud")._type, ItemTypeVirtualFile);
QCOMPARE(dbRecord(fakeFolder, "A/a1.owncloud")._fileSize, 65); QCOMPARE(dbRecord(fakeFolder, "A/a1.owncloud")._fileSize, 65);
cleanup(); cleanup();
// If the local placeholder file is removed, it'll just be recreated // If the local virtual file file is removed, it'll just be recreated
if (!doLocalDiscovery) if (!doLocalDiscovery)
fakeFolder.syncEngine().setLocalDiscoveryOptions(LocalDiscoveryStyle::DatabaseAndFilesystem, { "A" }); fakeFolder.syncEngine().setLocalDiscoveryOptions(LocalDiscoveryStyle::DatabaseAndFilesystem, { "A" });
fakeFolder.localModifier().remove("A/a1.owncloud"); fakeFolder.localModifier().remove("A/a1.owncloud");
@ -115,7 +115,7 @@ private slots:
QVERIFY(fakeFolder.currentLocalState().find("A/a1.owncloud")); QVERIFY(fakeFolder.currentLocalState().find("A/a1.owncloud"));
QVERIFY(fakeFolder.currentRemoteState().find("A/a1")); QVERIFY(fakeFolder.currentRemoteState().find("A/a1"));
QVERIFY(itemInstruction(completeSpy, "A/a1.owncloud", CSYNC_INSTRUCTION_NEW)); QVERIFY(itemInstruction(completeSpy, "A/a1.owncloud", CSYNC_INSTRUCTION_NEW));
QCOMPARE(dbRecord(fakeFolder, "A/a1.owncloud")._type, ItemTypePlaceholder); QCOMPARE(dbRecord(fakeFolder, "A/a1.owncloud")._type, ItemTypeVirtualFile);
QCOMPARE(dbRecord(fakeFolder, "A/a1.owncloud")._fileSize, 65); QCOMPARE(dbRecord(fakeFolder, "A/a1.owncloud")._fileSize, 65);
cleanup(); cleanup();
@ -129,7 +129,7 @@ private slots:
QVERIFY(!fakeFolder.currentRemoteState().find("A/a1")); QVERIFY(!fakeFolder.currentRemoteState().find("A/a1"));
QVERIFY(fakeFolder.currentRemoteState().find("A/a1m")); QVERIFY(fakeFolder.currentRemoteState().find("A/a1m"));
QVERIFY(itemInstruction(completeSpy, "A/a1m.owncloud", CSYNC_INSTRUCTION_RENAME)); QVERIFY(itemInstruction(completeSpy, "A/a1m.owncloud", CSYNC_INSTRUCTION_RENAME));
QCOMPARE(dbRecord(fakeFolder, "A/a1m.owncloud")._type, ItemTypePlaceholder); QCOMPARE(dbRecord(fakeFolder, "A/a1m.owncloud")._type, ItemTypeVirtualFile);
cleanup(); cleanup();
// Remote remove is propagated // Remote remove is propagated
@ -142,7 +142,7 @@ private slots:
QVERIFY(!dbRecord(fakeFolder, "A/a1m.owncloud").isValid()); QVERIFY(!dbRecord(fakeFolder, "A/a1m.owncloud").isValid());
cleanup(); cleanup();
// Edge case: Local placeholder but no db entry for some reason // Edge case: Local virtual file but no db entry for some reason
fakeFolder.remoteModifier().insert("A/a2", 64); fakeFolder.remoteModifier().insert("A/a2", 64);
fakeFolder.remoteModifier().insert("A/a3", 64); fakeFolder.remoteModifier().insert("A/a3", 64);
QVERIFY(fakeFolder.syncOnce()); QVERIFY(fakeFolder.syncOnce());
@ -163,11 +163,11 @@ private slots:
cleanup(); cleanup();
} }
void testPlaceholderConflict() void testVirtualFileConflict()
{ {
FakeFolder fakeFolder{ FileInfo() }; FakeFolder fakeFolder{ FileInfo() };
SyncOptions syncOptions; SyncOptions syncOptions;
syncOptions._newFilesArePlaceholders = true; syncOptions._newFilesAreVirtual = true;
fakeFolder.syncEngine().setSyncOptions(syncOptions); fakeFolder.syncEngine().setSyncOptions(syncOptions);
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItemPtr &))); QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItemPtr &)));
@ -177,7 +177,7 @@ private slots:
}; };
cleanup(); cleanup();
// Create a placeholder for a new remote file // Create a virtual file for a new remote file
fakeFolder.remoteModifier().mkdir("A"); fakeFolder.remoteModifier().mkdir("A");
fakeFolder.remoteModifier().insert("A/a1", 64); fakeFolder.remoteModifier().insert("A/a1", 64);
fakeFolder.remoteModifier().insert("A/a2", 64); fakeFolder.remoteModifier().insert("A/a2", 64);
@ -191,8 +191,8 @@ private slots:
QVERIFY(fakeFolder.currentLocalState().find("B/b2.owncloud")); QVERIFY(fakeFolder.currentLocalState().find("B/b2.owncloud"));
cleanup(); cleanup();
// A: the correct file and a conflicting file are added, placeholders stay // A: the correct file and a conflicting file are added, virtual files stay
// B: same setup, but the placeholders are deleted by the user // B: same setup, but the virtual files are deleted by the user
// C: user adds a *directory* locally // C: user adds a *directory* locally
fakeFolder.localModifier().insert("A/a1", 64); fakeFolder.localModifier().insert("A/a1", 64);
fakeFolder.localModifier().insert("A/a2", 30); fakeFolder.localModifier().insert("A/a2", 30);
@ -211,7 +211,7 @@ private slots:
QVERIFY(itemInstruction(completeSpy, "B/b2", CSYNC_INSTRUCTION_CONFLICT)); QVERIFY(itemInstruction(completeSpy, "B/b2", CSYNC_INSTRUCTION_CONFLICT));
QVERIFY(itemInstruction(completeSpy, "C/c1", CSYNC_INSTRUCTION_CONFLICT)); QVERIFY(itemInstruction(completeSpy, "C/c1", CSYNC_INSTRUCTION_CONFLICT));
// no placeholder files should remain // no virtual file files should remain
QVERIFY(!fakeFolder.currentLocalState().find("A/a1.owncloud")); QVERIFY(!fakeFolder.currentLocalState().find("A/a1.owncloud"));
QVERIFY(!fakeFolder.currentLocalState().find("A/a2.owncloud")); QVERIFY(!fakeFolder.currentLocalState().find("A/a2.owncloud"));
QVERIFY(!fakeFolder.currentLocalState().find("B/b1.owncloud")); QVERIFY(!fakeFolder.currentLocalState().find("B/b1.owncloud"));
@ -221,7 +221,7 @@ private slots:
// conflict files should exist // conflict files should exist
QCOMPARE(fakeFolder.syncJournal().conflictRecordPaths().size(), 3); QCOMPARE(fakeFolder.syncJournal().conflictRecordPaths().size(), 3);
// nothing should have the placeholder tag // nothing should have the virtual file tag
QCOMPARE(dbRecord(fakeFolder, "A/a1")._type, ItemTypeFile); QCOMPARE(dbRecord(fakeFolder, "A/a1")._type, ItemTypeFile);
QCOMPARE(dbRecord(fakeFolder, "A/a2")._type, ItemTypeFile); QCOMPARE(dbRecord(fakeFolder, "A/a2")._type, ItemTypeFile);
QCOMPARE(dbRecord(fakeFolder, "B/b1")._type, ItemTypeFile); QCOMPARE(dbRecord(fakeFolder, "B/b1")._type, ItemTypeFile);
@ -238,9 +238,9 @@ private slots:
void testWithNormalSync() void testWithNormalSync()
{ {
FakeFolder fakeFolder{FileInfo::A12_B12_C12_S12()}; FakeFolder fakeFolder{ FileInfo::A12_B12_C12_S12() };
SyncOptions syncOptions; SyncOptions syncOptions;
syncOptions._newFilesArePlaceholders = true; syncOptions._newFilesAreVirtual = true;
fakeFolder.syncEngine().setSyncOptions(syncOptions); fakeFolder.syncEngine().setSyncOptions(syncOptions);
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItemPtr &))); QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItemPtr &)));
@ -263,22 +263,22 @@ private slots:
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
cleanup(); cleanup();
// New files on the remote create placeholders // New files on the remote create virtual files
fakeFolder.remoteModifier().insert("A/new"); fakeFolder.remoteModifier().insert("A/new");
QVERIFY(fakeFolder.syncOnce()); QVERIFY(fakeFolder.syncOnce());
QVERIFY(!fakeFolder.currentLocalState().find("A/new")); QVERIFY(!fakeFolder.currentLocalState().find("A/new"));
QVERIFY(fakeFolder.currentLocalState().find("A/new.owncloud")); QVERIFY(fakeFolder.currentLocalState().find("A/new.owncloud"));
QVERIFY(fakeFolder.currentRemoteState().find("A/new")); QVERIFY(fakeFolder.currentRemoteState().find("A/new"));
QVERIFY(itemInstruction(completeSpy, "A/new.owncloud", CSYNC_INSTRUCTION_NEW)); QVERIFY(itemInstruction(completeSpy, "A/new.owncloud", CSYNC_INSTRUCTION_NEW));
QCOMPARE(dbRecord(fakeFolder, "A/new.owncloud")._type, ItemTypePlaceholder); QCOMPARE(dbRecord(fakeFolder, "A/new.owncloud")._type, ItemTypeVirtualFile);
cleanup(); cleanup();
} }
void testPlaceholderDownload() void testVirtualFileDownload()
{ {
FakeFolder fakeFolder{FileInfo()}; FakeFolder fakeFolder{ FileInfo() };
SyncOptions syncOptions; SyncOptions syncOptions;
syncOptions._newFilesArePlaceholders = true; syncOptions._newFilesAreVirtual = true;
fakeFolder.syncEngine().setSyncOptions(syncOptions); fakeFolder.syncEngine().setSyncOptions(syncOptions);
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItemPtr &))); QSignalSpy completeSpy(&fakeFolder.syncEngine(), SIGNAL(itemCompleted(const SyncFileItemPtr &)));
@ -294,11 +294,11 @@ private slots:
journal.getFileRecord(path + ".owncloud", &record); journal.getFileRecord(path + ".owncloud", &record);
if (!record.isValid()) if (!record.isValid())
return; return;
record._type = ItemTypePlaceholderDownload; record._type = ItemTypeVirtualFileDownload;
journal.setFileRecord(record); journal.setFileRecord(record);
}; };
// Create a placeholder for remote files // Create a virtual file for remote files
fakeFolder.remoteModifier().mkdir("A"); fakeFolder.remoteModifier().mkdir("A");
fakeFolder.remoteModifier().insert("A/a1"); fakeFolder.remoteModifier().insert("A/a1");
fakeFolder.remoteModifier().insert("A/a2"); fakeFolder.remoteModifier().insert("A/a2");
@ -354,33 +354,33 @@ private slots:
QVERIFY(!dbRecord(fakeFolder, "A/a6.owncloud").isValid()); QVERIFY(!dbRecord(fakeFolder, "A/a6.owncloud").isValid());
} }
// Check what might happen if an older sync client encounters placeholders // Check what might happen if an older sync client encounters virtual files
void testOldVersion1() void testOldVersion1()
{ {
FakeFolder fakeFolder{ FileInfo() }; FakeFolder fakeFolder{ FileInfo() };
SyncOptions syncOptions; SyncOptions syncOptions;
syncOptions._newFilesArePlaceholders = true; syncOptions._newFilesAreVirtual = true;
fakeFolder.syncEngine().setSyncOptions(syncOptions); fakeFolder.syncEngine().setSyncOptions(syncOptions);
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
// Create a placeholder // Create a virtual file
fakeFolder.remoteModifier().mkdir("A"); fakeFolder.remoteModifier().mkdir("A");
fakeFolder.remoteModifier().insert("A/a1"); fakeFolder.remoteModifier().insert("A/a1");
QVERIFY(fakeFolder.syncOnce()); QVERIFY(fakeFolder.syncOnce());
QVERIFY(fakeFolder.currentLocalState().find("A/a1.owncloud")); QVERIFY(fakeFolder.currentLocalState().find("A/a1.owncloud"));
// Simulate an old client by switching the type of all ItemTypePlaceholder // Simulate an old client by switching the type of all ItemTypeVirtualFile
// entries in the db to an invalid type. // entries in the db to an invalid type.
auto &db = fakeFolder.syncJournal(); auto &db = fakeFolder.syncJournal();
SyncJournalFileRecord rec; SyncJournalFileRecord rec;
db.getFileRecord(QByteArray("A/a1.owncloud"), &rec); db.getFileRecord(QByteArray("A/a1.owncloud"), &rec);
QVERIFY(rec.isValid()); QVERIFY(rec.isValid());
QCOMPARE(rec._type, ItemTypePlaceholder); QCOMPARE(rec._type, ItemTypeVirtualFile);
rec._type = static_cast<ItemType>(-1); rec._type = static_cast<ItemType>(-1);
db.setFileRecord(rec); db.setFileRecord(rec);
// Also switch off new files becoming placeholders // Also switch off new files becoming virtual files
syncOptions._newFilesArePlaceholders = false; syncOptions._newFilesAreVirtual = false;
fakeFolder.syncEngine().setSyncOptions(syncOptions); fakeFolder.syncEngine().setSyncOptions(syncOptions);
// A sync that doesn't do remote discovery has no effect // A sync that doesn't do remote discovery has no effect
@ -390,7 +390,7 @@ private slots:
QVERIFY(fakeFolder.currentRemoteState().find("A/a1")); QVERIFY(fakeFolder.currentRemoteState().find("A/a1"));
QVERIFY(!fakeFolder.currentRemoteState().find("A/a1.owncloud")); QVERIFY(!fakeFolder.currentRemoteState().find("A/a1.owncloud"));
// But with a remote discovery the placeholders will be removed and // But with a remote discovery the virtual files will be removed and
// the remote files will be downloaded. // the remote files will be downloaded.
db.forceRemoteDiscoveryNextSync(); db.forceRemoteDiscoveryNextSync();
QVERIFY(fakeFolder.syncOnce()); QVERIFY(fakeFolder.syncOnce());
@ -410,22 +410,22 @@ private slots:
QVERIFY(fakeFolder.syncOnce()); QVERIFY(fakeFolder.syncOnce());
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
// Create the placeholder too // Create the virtual file too
// In the wild, the new version would create the placeholder and the db entry // In the wild, the new version would create the virtual file and the db entry
// while the old version would download the plain file. // while the old version would download the plain file.
fakeFolder.localModifier().insert("A/a1.owncloud"); fakeFolder.localModifier().insert("A/a1.owncloud");
auto &db = fakeFolder.syncJournal(); auto &db = fakeFolder.syncJournal();
SyncJournalFileRecord rec; SyncJournalFileRecord rec;
db.getFileRecord(QByteArray("A/a1"), &rec); db.getFileRecord(QByteArray("A/a1"), &rec);
rec._type = ItemTypePlaceholder; rec._type = ItemTypeVirtualFile;
rec._path = "A/a1.owncloud"; rec._path = "A/a1.owncloud";
db.setFileRecord(rec); db.setFileRecord(rec);
SyncOptions syncOptions; SyncOptions syncOptions;
syncOptions._newFilesArePlaceholders = true; syncOptions._newFilesAreVirtual = true;
fakeFolder.syncEngine().setSyncOptions(syncOptions); fakeFolder.syncEngine().setSyncOptions(syncOptions);
// Check that a sync removes the placeholder and its db entry // Check that a sync removes the virtual file and its db entry
QVERIFY(fakeFolder.syncOnce()); QVERIFY(fakeFolder.syncOnce());
QVERIFY(!fakeFolder.currentLocalState().find("A/a1.owncloud")); QVERIFY(!fakeFolder.currentLocalState().find("A/a1.owncloud"));
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
@ -433,5 +433,5 @@ private slots:
} }
}; };
QTEST_GUILESS_MAIN(TestSyncPlaceholders) QTEST_GUILESS_MAIN(TestSyncVirtualFiles)
#include "testsyncplaceholders.moc" #include "testsyncvirtualfiles.moc"