From: Christian Kamm Date: Thu, 3 May 2018 09:17:57 +0000 (+0200) Subject: Placeholder: Stop adding ignore pattern X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~21^2~468^2~590 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=4e3f2f755a9e0d430aae7a549a077511be1eb3c6;p=nextcloud-desktop.git Placeholder: Stop adding ignore pattern Because we can't make older clients preserve the version directive that was attached to it. See #6504 and #6498 --- diff --git a/src/csync/csync_exclude.cpp b/src/csync/csync_exclude.cpp index 1bc5a6c5d..f3a610ec0 100644 --- a/src/csync/csync_exclude.cpp +++ b/src/csync/csync_exclude.cpp @@ -320,29 +320,6 @@ void ExcludedFiles::setClientVersion(ExcludedFiles::Version version) _clientVersion = version; } -void ExcludedFiles::setupPlaceholderExclude( - const QString &excludeFile, const QByteArray &placeholderExtension) -{ - if (!QFile::exists(excludeFile)) { - // Ensure the parent paths exist - QDir().mkpath(QFileInfo(excludeFile).dir().absolutePath()); - } else { - // Does the exclude file contain the exclude already? - QFile file(excludeFile); - file.open(QIODevice::ReadOnly | QIODevice::Text); - auto data = file.readAll(); - file.close(); - if (data.contains("\n*" + placeholderExtension + "\n")) - return; - } - - // Add it to the file - QFile file(excludeFile); - file.open(QIODevice::ReadWrite | QIODevice::Append); - file.write("\n#!version < 2.5.0\n*" + placeholderExtension + "\n"); - file.close(); -} - bool ExcludedFiles::loadExcludeFile(const QByteArray & basePath, const QString & file) { QFile f(file); diff --git a/src/csync/csync_exclude.h b/src/csync/csync_exclude.h index 4267aa14f..c470da13f 100644 --- a/src/csync/csync_exclude.h +++ b/src/csync/csync_exclude.h @@ -132,12 +132,6 @@ public: auto csyncTraversalMatchFun() -> std::function; - /** - * Adds the exclude that skips placeholder files in older versions - * to the user exclude file. - */ - static void setupPlaceholderExclude(const QString &excludeFile, const QByteArray &placeholderExtension); - public slots: /** * Reloads the exclude patterns from the registered paths. diff --git a/src/gui/application.cpp b/src/gui/application.cpp index 8490547c0..ee4d84abb 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -192,9 +192,6 @@ Application::Application(int &argc, char **argv) if (!AbstractNetworkJob::httpTimeout) AbstractNetworkJob::httpTimeout = cfg.timeout(); - ExcludedFiles::setupPlaceholderExclude( - cfg.excludeFile(ConfigFile::UserScope), APPLICATION_DOTPLACEHOLDER_SUFFIX); - _folderManager.reset(new FolderMan); connect(this, &SharedTools::QtSingleApplication::messageReceived, this, &Application::slotParseMessage); diff --git a/test/csync/csync_tests/check_csync_exclude.cpp b/test/csync/csync_tests/check_csync_exclude.cpp index 31af71ad0..97aa7bb5b 100644 --- a/test/csync/csync_tests/check_csync_exclude.cpp +++ b/test/csync/csync_tests/check_csync_exclude.cpp @@ -696,53 +696,6 @@ static void check_csync_exclude_expand_escapes(void **state) assert_true(0 == strcmp(line.constData(), "\\")); } -static void check_placeholder_exclude(void **state) -{ - (void)state; - - auto readFile = [](const QString &file) { - QFile f(file); - f.open(QIODevice::ReadOnly | QIODevice::Text); - return f.readAll(); - }; - - QTemporaryDir tempDir; - QString path; - QByteArray expected = "\n#!version < 2.5.0\n*.owncloud\n"; - - // Case 1: No file exists yet, parent dirs are missing too - path = tempDir.path() + "/foo/bar/exclude.lst"; - ExcludedFiles::setupPlaceholderExclude(path, ".owncloud"); - - assert_true(QFile::exists(path)); - assert_true(readFile(path) == expected); - - // Case 2: Running it again - ExcludedFiles::setupPlaceholderExclude(path, ".owncloud"); - assert_true(readFile(path) == expected); - - // Case 3: File exists, has some data - { - QFile f(path); - f.open(QIODevice::WriteOnly | QIODevice::Truncate); - f.write("# bla\nmyexclude\n\nanotherexclude"); - f.close(); - } - ExcludedFiles::setupPlaceholderExclude(path, ".owncloud"); - assert_true(readFile(path) == "# bla\nmyexclude\n\nanotherexclude" + expected); - - // Case 4: Running it again still does nothing - ExcludedFiles::setupPlaceholderExclude(path, ".owncloud"); - assert_true(readFile(path) == "# bla\nmyexclude\n\nanotherexclude" + expected); - - // Case 5: Verify that reading this file doesn't actually include the exclude - ExcludedFiles excludes; - excludes.addExcludeFilePath(path); - excludes.reloadExcludeFiles(); - assert_false(excludes._allExcludes.value("/").contains("*.owncloud")); - assert_true(excludes._allExcludes.value("/").contains("myexclude")); -} - static void check_version_directive(void **state) { (void)state; @@ -792,7 +745,6 @@ int torture_run_tests(void) cmocka_unit_test_setup_teardown(T::check_csync_is_windows_reserved_word, T::setup_init, T::teardown), cmocka_unit_test_setup_teardown(T::check_csync_excluded_performance, T::setup_init, T::teardown), cmocka_unit_test(T::check_csync_exclude_expand_escapes), - cmocka_unit_test(T::check_placeholder_exclude), cmocka_unit_test(T::check_version_directive), };