From: allexzander Date: Thu, 11 Feb 2021 21:21:12 +0000 (+0200) Subject: Fix incorrect logger output for non-latin strings. X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~21^2~358^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=4d66d209bc4d46e42a97ba20cda908be84702093;p=nextcloud-desktop.git Fix incorrect logger output for non-latin strings. Signed-off-by: allexzander --- diff --git a/src/common/ownsql.h b/src/common/ownsql.h index 894bef85b..300bdc482 100644 --- a/src/common/ownsql.h +++ b/src/common/ownsql.h @@ -152,6 +152,12 @@ public: bindValueInternal(pos, value); } + void bindValue(int pos, const QByteArray &value) + { + qCDebug(lcSql) << "SQL bind" << pos << QString::fromUtf8(value); + bindValueInternal(pos, value); + } + const QByteArray &lastQuery() const; int numRowsAffected(); void reset_and_clear_bindings(); diff --git a/src/common/syncjournaldb.cpp b/src/common/syncjournaldb.cpp index 8e2a6d81a..ff6aafa3e 100644 --- a/src/common/syncjournaldb.cpp +++ b/src/common/syncjournaldb.cpp @@ -909,11 +909,11 @@ bool SyncJournalDb::setFileRecord(const SyncJournalFileRecord &_record) } } - qCInfo(lcDb) << "Updating file record for path:" << record._path << "inode:" << record._inode + qCInfo(lcDb) << "Updating file record for path:" << record.path() << "inode:" << record._inode << "modtime:" << record._modtime << "type:" << record._type << "etag:" << record._etag << "fileId:" << record._fileId << "remotePerm:" << record._remotePerm.toString() << "fileSize:" << record._fileSize << "checksum:" << record._checksumHeader - << "e2eMangledName:" << record._e2eMangledName << "isE2eEncrypted:" << record._isE2eEncrypted; + << "e2eMangledName:" << record.e2eMangledName() << "isE2eEncrypted:" << record._isE2eEncrypted; qlonglong phash = getPHash(record._path); if (checkConnect()) { @@ -1241,7 +1241,7 @@ bool SyncJournalDb::listFilesInPath(const QByteArray& path, SyncJournalFileRecord rec; fillFileRecordFromGetQuery(rec, _listFilesInPathQuery); if (!rec._path.startsWith(path) || rec._path.indexOf("/", path.size() + 1) > 0) { - qWarning(lcDb) << "hash collision" << path << rec._path; + qWarning(lcDb) << "hash collision" << path << rec.path(); continue; } rowCallback(rec); diff --git a/src/common/syncjournalfilerecord.h b/src/common/syncjournalfilerecord.h index 3a8643fe8..b47f98e5b 100644 --- a/src/common/syncjournalfilerecord.h +++ b/src/common/syncjournalfilerecord.h @@ -55,6 +55,8 @@ public: bool isDirectory() const { return _type == ItemTypeDirectory; } bool isFile() const { return _type == ItemTypeFile || _type == ItemTypeVirtualFileDehydration; } bool isVirtualFile() const { return _type == ItemTypeVirtualFile || _type == ItemTypeVirtualFileDownload; } + QString path() const { return QString::fromUtf8(_path); } + QString e2eMangledName() const { return QString::fromUtf8(_e2eMangledName); } QByteArray _path; quint64 _inode = 0; diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index 6c0254600..95cb7bf34 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -319,7 +319,7 @@ void ProcessDirectoryJob::processFile(PathTuple path, << " | inode: " << dbEntry._inode << "/" << localEntry.inode << "/" << " | type: " << dbEntry._type << "/" << localEntry.type << "/" << (serverEntry.isDirectory ? ItemTypeDirectory : ItemTypeFile) << " | e2ee: " << dbEntry._isE2eEncrypted << "/" << serverEntry.isE2eEncrypted - << " | e2eeMangledName: " << dbEntry._e2eMangledName << "/" << serverEntry.e2eMangledName; + << " | e2eeMangledName: " << dbEntry.e2eMangledName() << "/" << serverEntry.e2eMangledName; if (_discoveryData->isRenamed(path._original)) { qCDebug(lcDisco) << "Ignoring renamed"; @@ -564,7 +564,7 @@ void ProcessDirectoryJob::processFileAnalyzeRemoteInfo( } // Now we know there is a sane rename candidate. - QString originalPath = QString::fromUtf8(base._path); + QString originalPath = base.path(); if (_discoveryData->isRenamed(originalPath)) { qCInfo(lcDisco, "folder already has a rename entry, skipping"); @@ -896,7 +896,7 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo( dbError(); return; } - const auto originalPath = QString::fromUtf8(base._path); + const auto originalPath = base.path(); // Function to gradually check conditions for accepting a move-candidate auto moveCheck = [&]() { diff --git a/src/libsync/logger.cpp b/src/libsync/logger.cpp index 1b7b8791a..9a45e6059 100644 --- a/src/libsync/logger.cpp +++ b/src/libsync/logger.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -198,6 +199,7 @@ void Logger::setLogFile(const QString &name) } _logstream.reset(new QTextStream(&_logFile)); + _logstream->setCodec(QTextCodec::codecForName("UTF-8")); } void Logger::setLogExpire(int expire) diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp index 9893058b7..f6a23261a 100644 --- a/src/libsync/syncengine.cpp +++ b/src/libsync/syncengine.cpp @@ -989,14 +989,14 @@ void SyncEngine::wipeVirtualFiles(const QString &localPath, SyncJournalDb &journ if (rec._type != ItemTypeVirtualFile && rec._type != ItemTypeVirtualFileDownload) return; - qCDebug(lcEngine) << "Removing db record for" << rec._path; + qCDebug(lcEngine) << "Removing db record for" << rec.path(); journal.deleteFileRecord(rec._path); // If the local file is a dehydrated placeholder, wipe it too. // Otherwise leave it to allow the next sync to have a new-new conflict. QString localFile = localPath + rec._path; if (QFile::exists(localFile) && vfs.isDehydratedPlaceholder(localFile)) { - qCDebug(lcEngine) << "Removing local dehydrated placeholder" << rec._path; + qCDebug(lcEngine) << "Removing local dehydrated placeholder" << rec.path(); QFile::remove(localFile); } }); diff --git a/src/libsync/syncfileitem.cpp b/src/libsync/syncfileitem.cpp index de33eb70f..cc7afe0f0 100644 --- a/src/libsync/syncfileitem.cpp +++ b/src/libsync/syncfileitem.cpp @@ -63,7 +63,7 @@ SyncJournalFileRecord SyncFileItem::toSyncJournalFileRecordWithInode(const QStri SyncFileItemPtr SyncFileItem::fromSyncJournalFileRecord(const SyncJournalFileRecord &rec) { auto item = SyncFileItemPtr::create(); - item->_file = QString::fromUtf8(rec._path); + item->_file = rec.path(); item->_inode = rec._inode; item->_modtime = rec._modtime; item->_type = rec._type; @@ -73,7 +73,7 @@ SyncFileItemPtr SyncFileItem::fromSyncJournalFileRecord(const SyncJournalFileRec item->_remotePerm = rec._remotePerm; item->_serverHasIgnoredFiles = rec._serverHasIgnoredFiles; item->_checksumHeader = rec._checksumHeader; - item->_encryptedFileName = QString::fromUtf8(rec._e2eMangledName); + item->_encryptedFileName = rec.e2eMangledName(); item->_isEncrypted = rec._isE2eEncrypted; return item; } diff --git a/test/syncenginetestutils.cpp b/test/syncenginetestutils.cpp index aba75d6c4..88d276e49 100644 --- a/test/syncenginetestutils.cpp +++ b/test/syncenginetestutils.cpp @@ -995,7 +995,7 @@ FileInfo FakeFolder::dbState() const { FileInfo result; _journalDb->getFilesBelowPath("", [&](const OCC::SyncJournalFileRecord &record) { - auto components = PathComponents(QString::fromUtf8(record._path)); + auto components = PathComponents(record.path()); auto &parentDir = findOrCreateDirs(result, components.parentDirComponents()); auto name = components.fileName(); auto &item = parentDir.children[name];