Skip to content

Commit aaf4a70

Browse files
erikjvTheOneRing
authored andcommitted
Check the correct path for .sync_*.db and ._sync_*.db
The dir() method will return the *parent* directory of the file/directory in the QFileInfo. So if "~/ownCloud" was passed in as the path, the check for .sync_*.db would be done on "~/". Because we're migrating from ._sync_*.db to .sync_*.db, it will now also check for the old filename. Fixes: #8849
1 parent c4d9118 commit aaf4a70

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/gui/folderman.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1329,7 +1329,7 @@ static QString checkPathValidityRecursive(const QString &path)
13291329
Utility::NtfsPermissionLookupRAII ntfs_perm;
13301330
#endif
13311331
const QFileInfo selFile(path);
1332-
if (!selFile.dir().entryList({ QStringLiteral(".sync_*.db") }, QDir::Hidden | QDir::Files).isEmpty()) {
1332+
if (!QDir(path).entryList({ QStringLiteral(".sync_*.db"), QStringLiteral("._sync_*.db") }, QDir::Hidden | QDir::Files).isEmpty()) {
13331333
return FolderMan::tr("The folder %1 is used in a folder sync connection!").arg(QDir::toNativeSeparators(selFile.filePath()));
13341334
}
13351335

test/testfolderman.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,26 @@ private slots:
128128
QDir(dirPath + "/ownCloud2/").removeRecursively();
129129
QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/ownCloud2/blublu").isNull());
130130
QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/ownCloud2/sub/subsub/sub").isNull());
131+
132+
{ // check for rejection of a directory with `.sync_*.db`
133+
QVERIFY(dir2.mkpath("db-check1"));
134+
QVERIFY(folderman->checkPathValidityForNewFolder(dirPath + "/db-check1").isNull());
135+
QFile f(dirPath + "/db-check1/.sync_something.db");
136+
QVERIFY(f.open(QFile::Truncate | QFile::WriteOnly));
137+
f.close();
138+
QVERIFY(QFileInfo::exists(dirPath + "/db-check1/.sync_something.db"));
139+
QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/db-check1").isNull());
140+
}
141+
142+
{ // check for rejection of a directory with `._sync_*.db`
143+
QVERIFY(dir2.mkpath("db-check2"));
144+
QVERIFY(folderman->checkPathValidityForNewFolder(dirPath + "/db-check2").isNull());
145+
QFile f(dirPath + "/db-check2/._sync_something.db");
146+
QVERIFY(f.open(QFile::Truncate | QFile::WriteOnly));
147+
f.close();
148+
QVERIFY(QFileInfo::exists(dirPath + "/db-check2/._sync_something.db"));
149+
QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/db-check2").isNull());
150+
}
131151
}
132152

133153
void testFindGoodPathForNewSyncFolder()

0 commit comments

Comments
 (0)