Explorar o código

Fix MacOS UTF-8 normalization issue

Signed-off-by: xavi-b <developer@xavi-b.fr>
xavi-b %!s(int64=3) %!d(string=hai) anos
pai
achega
5113802daf
Modificáronse 1 ficheiros con 7 adicións e 2 borrados
  1. 7 2
      src/common/syncjournaldb.cpp

+ 7 - 2
src/common/syncjournaldb.cpp

@@ -882,10 +882,15 @@ QVector<QByteArray> SyncJournalDb::tableColumns(const QByteArray &table)
 
 qint64 SyncJournalDb::getPHash(const QByteArray &file)
 {
+    QByteArray bytes = file;
+#ifdef Q_OS_MAC
+    bytes = QString::fromUtf8(file).normalized(QString::NormalizationForm_C).toUtf8();
+#endif
+
     qint64 h = 0;
-    int len = file.length();
+    int len = bytes.length();
 
-    h = c_jhash64((uint8_t *)file.data(), len, 0);
+    h = c_jhash64((uint8_t *)bytes.data(), len, 0);
     return h;
 }