Placeholder: Stop adding ignore pattern
authorChristian Kamm <mail@ckamm.de>
Thu, 3 May 2018 09:17:57 +0000 (11:17 +0200)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 15 Dec 2020 09:57:52 +0000 (10:57 +0100)
Because we can't make older clients preserve the version directive that
was attached to it.

See #6504 and #6498

src/csync/csync_exclude.cpp
src/csync/csync_exclude.h
src/gui/application.cpp
test/csync/csync_tests/check_csync_exclude.cpp

index 1bc5a6c5ddafab48536a7a47490ee7ebac72aac4..f3a610ec0ff841ec601bae97fa76f22c8b7d645d 100644 (file)
@@ -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);
index 4267aa14fcb961bfaab4a1df7901ae90b759a4ae..c470da13f48114a44be0c66293bf21082fd71c1d 100644 (file)
@@ -132,12 +132,6 @@ public:
     auto csyncTraversalMatchFun()
         -> std::function<CSYNC_EXCLUDE_TYPE(const char *path, ItemType filetype)>;
 
-    /**
-     * 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.
index 8490547c0d4aeb4f67dffea2705dfbf88369baf4..ee4d84abbcb4fb2741e55f0f349ea346a213f0ee 100644 (file)
@@ -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);
index 31af71ad0243ac544f61d357857b2b167980db78..97aa7bb5b99a779c646022b773ac56278828b01f 100644 (file)
@@ -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),
     };