match = CSYNC_FILE_SILENTLY_EXCLUDED;
goto out;
}
+ rc = csync_fnmatch(".sync_*.db*", bname, 0);
+ if (rc == 0) {
+ match = CSYNC_FILE_SILENTLY_EXCLUDED;
+ goto out;
+ }
rc = csync_fnmatch(".csync_journal.db*", bname, 0);
if (rc == 0) {
match = CSYNC_FILE_SILENTLY_EXCLUDED;
assert_int_equal(rc, CSYNC_FILE_SILENTLY_EXCLUDED);
rc = csync_excluded_no_ctx(csync->excludes, "subdir/._sync_5bdd60bdfcfa.db", CSYNC_FTW_TYPE_FILE);
assert_int_equal(rc, CSYNC_FILE_SILENTLY_EXCLUDED);
-
+
+ rc = csync_excluded_no_ctx(csync->excludes, ".sync_5bdd60bdfcfa.db", CSYNC_FTW_TYPE_FILE);
+ assert_int_equal(rc, CSYNC_FILE_SILENTLY_EXCLUDED);
+ rc = csync_excluded_no_ctx(csync->excludes, ".sync_5bdd60bdfcfa.db.ctmp", CSYNC_FTW_TYPE_FILE);
+ assert_int_equal(rc, CSYNC_FILE_SILENTLY_EXCLUDED);
+ rc = csync_excluded_no_ctx(csync->excludes, ".sync_5bdd60bdfcfa.db-shm", CSYNC_FTW_TYPE_FILE);
+ assert_int_equal(rc, CSYNC_FILE_SILENTLY_EXCLUDED);
+ rc = csync_excluded_no_ctx(csync->excludes, "subdir/.sync_5bdd60bdfcfa.db", CSYNC_FTW_TYPE_FILE);
+ assert_int_equal(rc, CSYNC_FILE_SILENTLY_EXCLUDED);
+
/* pattern ]*.directory - ignore and remove */
rc = csync_excluded_no_ctx(csync->excludes, "my.~directory", CSYNC_FTW_TYPE_FILE);
}
Cmd cmd;
- QString dbPath = options.source_dir + SyncJournalDb::makeDbName(credentialFreeUrl, folder, user);
+ QString dbPath = options.source_dir + SyncJournalDb::makeDbName(options.source_dir, credentialFreeUrl, folder, user);
SyncJournalDb db(dbPath);
if (!selectiveSyncList.empty()) {
QString FolderDefinition::defaultJournalPath(AccountPtr account)
{
- return SyncJournalDb::makeDbName(account->url(), targetPath, account->credentials()->user());
+ return SyncJournalDb::makeDbName(localPath, account->url(), targetPath, account->credentials()->user());
}
} // namespace OCC
foreach (const auto& folderAlias, settings.childGroups()) {
FolderDefinition folderDefinition;
if (FolderDefinition::load(settings, folderAlias, &folderDefinition)) {
+ auto defaultJournalPath = folderDefinition.defaultJournalPath(account->account());
+
// Migration: Old settings don't have journalPath
if (folderDefinition.journalPath.isEmpty()) {
- folderDefinition.journalPath = folderDefinition.defaultJournalPath(account->account());
+ folderDefinition.journalPath = defaultJournalPath;
+ }
+
+ // Migration: ._ files sometimes don't work
+ // So if the configured journalPath is the default one ("._sync_*.db")
+ // but the current default doesn't have the underscore, switch to the
+ // new default. See SyncJournalDb::makeDbName().
+ if (folderDefinition.journalPath.startsWith("._sync_")
+ && defaultJournalPath.startsWith(".sync_")) {
+ folderDefinition.journalPath = defaultJournalPath;
}
- folderDefinition.defaultJournalPath(account->account());
+
// Migration: If an old db is found, move it to the new name.
if (backwardsCompatible) {
SyncJournalDb::maybeMigrateDb(folderDefinition.localPath, folderDefinition.absoluteJournalPath());
// qDebug() << Q_FUNC_INFO << event->name;
if (fileName.startsWith("._sync_") ||
fileName.startsWith(".csync_journal.db") ||
- fileName.startsWith(".owncloudsync.log")) {
+ fileName.startsWith(".owncloudsync.log") ||
+ fileName.startsWith(".sync_")) {
// qDebug() << "ignore journal";
} else {
const QString p = _watches[event->wd] + '/' + fileName;
#include <QDebug>
#include <QElapsedTimer>
#include <QUrl>
+#include <QDir>
#include "ownsql.h"
}
-QString SyncJournalDb::makeDbName(const QUrl& remoteUrl,
+QString SyncJournalDb::makeDbName(const QString& localPath,
+ const QUrl& remoteUrl,
const QString& remotePath,
const QString& user)
{
journalPath.append( ba.left(6).toHex() );
journalPath.append(".db");
+ // If the journal doesn't exist and we can't create a file
+ // at that location, try again with a journal name that doesn't
+ // have the ._ prefix.
+ //
+ // The disadvantage of that filename is that it will only be ignored
+ // by client versions >2.3.2.
+ //
+ // See #5633: "._*" is often forbidden on samba shared folders.
+
+ // If it exists already, the path is clearly usable
+ QFile file(QDir(localPath).filePath(journalPath));
+ if (file.exists()) {
+ return journalPath;
+ }
+
+ // Try to create a file there
+ if (file.open(QIODevice::ReadWrite)) {
+ // Ok, all good.
+ file.close();
+ file.remove();
+ return journalPath;
+ }
+
+ // Can we create it if we drop the underscore?
+ QString alternateJournalPath = journalPath.mid(2).prepend(".");
+ QFile file2(QDir(localPath).filePath(alternateJournalPath));
+ if (file2.open(QIODevice::ReadWrite)) {
+ // The alternative worked, use it
+ qDebug() << "Using alternate database path" << alternateJournalPath;
+ file2.close();
+ file2.remove();
+ return alternateJournalPath;
+ }
+
+ // Neither worked, just keep the original and throw errors later
+ qDebug() << "Could not find a writable database path" << file.fileName();
return journalPath;
}
virtual ~SyncJournalDb();
/// Create a journal path for a specific configuration
- static QString makeDbName(const QUrl& remoteUrl,
+ static QString makeDbName(const QString& localPath,
+ const QUrl& remoteUrl,
const QString& remotePath,
const QString& user);