Skip to content

Commit

Permalink
Normalize file names before using them as keys
Browse files Browse the repository at this point in the history
On macOS the filenames on disk are stored in NFD form. When the original
filename on the server was in NFC form, the filenames wouldn't match,
and a MOVE or DELETE+PUT would be triggered.

This changes converts all filenames to NFC form during local discovery.
  • Loading branch information
erikjv committed Dec 5, 2024
1 parent 19751ff commit dd40586
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/libsync/discovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ void ProcessDirectoryJob::process()
};
std::map<QString, Entries> entries;
for (auto &e : _serverNormalQueryEntries) {
entries[e.name].serverEntry = std::move(e);
// Keep the name on the server as-is, but use the NFC form as the key
entries[e.name.normalized(QString::NormalizationForm_C)].serverEntry = std::move(e);
}
_serverNormalQueryEntries.clear();

Expand All @@ -93,7 +94,7 @@ void ProcessDirectoryJob::process()
if (rec.isVirtualFile() && isVfsWithSuffix()) {
name = chopVirtualFileSuffix(name);
}
auto &dbEntry = entries[name].dbEntry;
auto &dbEntry = entries[name.normalized(QString::NormalizationForm_C)].dbEntry;
dbEntry = rec;
setupDbPinStateActions(dbEntry);
})) {
Expand All @@ -102,6 +103,7 @@ void ProcessDirectoryJob::process()
}

for (auto &e : _localNormalQueryEntries) {
e.name = e.name.normalized(QString::NormalizationForm_C);
entries[e.name].localEntry = e;
}
if (isVfsWithSuffix()) {
Expand Down Expand Up @@ -141,7 +143,7 @@ void ProcessDirectoryJob::process()
const auto &e = f.second;

PathTuple path;
path = _currentFolder.addName(e.nameOverride.isEmpty() ? f.first : e.nameOverride);
path = _currentFolder.addName(e.nameOverride.isEmpty() ? f.second.serverEntry.name : e.nameOverride);

if (isVfsWithSuffix()) {
// Without suffix vfs the paths would be good. But since the dbEntry and localEntry
Expand Down

0 comments on commit dd40586

Please sign in to comment.