From: Christian Kamm Date: Thu, 22 Jun 2017 12:06:31 +0000 (+0200) Subject: Merge remote-tracking branch 'origin/2.3' X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~710^2~3 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=15ee7b39ac317c4afaee4752ebb2767745870366;p=nextcloud-desktop.git Merge remote-tracking branch 'origin/2.3' --- 15ee7b39ac317c4afaee4752ebb2767745870366 diff --cc src/gui/folderman.cpp index 6c9fd71cf,cb0fa90b5..ce5376b2b --- a/src/gui/folderman.cpp +++ b/src/gui/folderman.cpp @@@ -236,14 -232,25 +236,25 @@@ int FolderMan::setupFolders( void FolderMan::setupFoldersHelper(QSettings &settings, AccountStatePtr account, bool backwardsCompatible) { - foreach (const auto& folderAlias, settings.childGroups()) { + 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()); diff --cc src/gui/folderwatcher_linux.cpp index b505b8dd0,d647f6595..5d2d4e7fd --- a/src/gui/folderwatcher_linux.cpp +++ b/src/gui/folderwatcher_linux.cpp @@@ -160,9 -168,15 +160,12 @@@ void FolderWatcherPrivate::slotReceived // Fire event for the path that was changed. if (event->len > 0 && event->wd > -1) { QByteArray fileName(event->name); - if (fileName.startsWith("._sync_") || fileName.startsWith(".csync_journal.db") || fileName.startsWith(".owncloudsync.log")) { - // qDebug() << Q_FUNC_INFO << event->name; - if (fileName.startsWith("._sync_") || - fileName.startsWith(".csync_journal.db") || - fileName.startsWith(".owncloudsync.log") || - fileName.startsWith(".sync_")) { - // qDebug() << "ignore journal"; ++ if (fileName.startsWith("._sync_") ++ || fileName.startsWith(".csync_journal.db") ++ || fileName.startsWith(".owncloudsync.log") ++ || fileName.startsWith(".sync_")) { } else { const QString p = _watches[event->wd] + '/' + fileName; - //qDebug() << "found a change in " << p; _parent->changeDetected(p); } } diff --cc src/gui/ignorelisteditor.cpp index 83fd39ffd,1d124d1d6..64c39c48f --- a/src/gui/ignorelisteditor.cpp +++ b/src/gui/ignorelisteditor.cpp @@@ -46,8 -46,11 +46,11 @@@ IgnoreListEditor::IgnoreListEditor(QWid ConfigFile cfgFile; readOnlyTooltip = tr("This entry is provided by the system at '%1' " "and cannot be modified in this view.") - .arg(QDir::toNativeSeparators(cfgFile.excludeFile(ConfigFile::SystemScope))); + .arg(QDir::toNativeSeparators(cfgFile.excludeFile(ConfigFile::SystemScope))); + addPattern(".csync_journal.db*", /*deletable=*/false, /*readonly=*/true); + addPattern("._sync_*.db*", /*deletable=*/false, /*readonly=*/true); + addPattern(".sync_*.db*", /*deletable=*/false, /*readonly=*/true); readIgnoreFile(cfgFile.excludeFile(ConfigFile::SystemScope), true); readIgnoreFile(cfgFile.excludeFile(ConfigFile::UserScope), false); diff --cc src/libsync/syncjournaldb.cpp index 3406c7e35,c6c4a9cd5..b6bcff4d0 --- a/src/libsync/syncjournaldb.cpp +++ b/src/libsync/syncjournaldb.cpp @@@ -13,10 -13,11 +13,11 @@@ */ #include +#include #include -#include #include #include + #include #include "ownsql.h" @@@ -34,27 -34,66 +35,64 @@@ namespace OCC { -SyncJournalDb::SyncJournalDb(const QString& dbFilePath, QObject *parent) : - QObject(parent), - _dbFile(dbFilePath), - _transaction(0) -{ +Q_LOGGING_CATEGORY(lcDb, "sync.database", QtInfoMsg) +SyncJournalDb::SyncJournalDb(const QString &dbFilePath, QObject *parent) + : QObject(parent) + , _dbFile(dbFilePath) + , _transaction(0) +{ } - QString SyncJournalDb::makeDbName(const QUrl &remoteUrl, -QString SyncJournalDb::makeDbName(const QString& localPath, - const QUrl& remoteUrl, - const QString& remotePath, - const QString& user) ++QString SyncJournalDb::makeDbName(const QString &localPath, ++ const QUrl &remoteUrl, + const QString &remotePath, + const QString &user) { QString journalPath = QLatin1String("._sync_"); - QString key = QString::fromUtf8("%1@%2:%3").arg( - user, - remoteUrl.toString(), - remotePath); + QString key = QString::fromUtf8("%1@%2:%3").arg(user, remoteUrl.toString(), remotePath); QByteArray ba = QCryptographicHash::hash(key.toUtf8(), QCryptographicHash::Md5); - journalPath.append( ba.left(6).toHex() ); + 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; ++ qCInfo(lcDb) << "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(); ++ qCWarning(lcDb) << "Could not find a writable database path" << file.fileName(); return journalPath; } diff --cc src/libsync/syncjournaldb.h index f51d5b9c1,37df8c81e..3f6c89e43 --- a/src/libsync/syncjournaldb.h +++ b/src/libsync/syncjournaldb.h @@@ -41,12 -41,13 +41,13 @@@ public 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); ++ static QString makeDbName(const QString &localPath, ++ const QUrl &remoteUrl, + const QString &remotePath, + const QString &user); /// Migrate a csync_journal to the new path, if necessary. Returns false on error - static bool maybeMigrateDb(const QString& localPath, const QString& absoluteJournalPath); + static bool maybeMigrateDb(const QString &localPath, const QString &absoluteJournalPath); // to verify that the record could be queried successfully check // with SyncJournalFileRecord::isValid()