Skip to content

Commit

Permalink
Added conversion functions to 'path' and 'e2eMangledName' for convini…
Browse files Browse the repository at this point in the history
…ence.

Signed-off-by: allexzander <[email protected]>
  • Loading branch information
allexzander committed Feb 15, 2021
1 parent cdc6e88 commit 32d1f0e
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/common/syncjournaldb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -909,11 +909,11 @@ bool SyncJournalDb::setFileRecord(const SyncJournalFileRecord &_record)
}
}

qCInfo(lcDb) << "Updating file record for path:" << QString::fromUtf8(record._path) << "inode:" << record._inode
qCInfo(lcDb) << "Updating file record for path:" << record.pathFromUtf8() << "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.e2eMangledNameFromUtf8() << "isE2eEncrypted:" << record._isE2eEncrypted;

qlonglong phash = getPHash(record._path);
if (checkConnect()) {
Expand Down Expand Up @@ -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.pathFromUtf8();
continue;
}
rowCallback(rec);
Expand Down
2 changes: 2 additions & 0 deletions src/common/syncjournalfilerecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class OCSYNC_EXPORT SyncJournalFileRecord
bool isDirectory() const { return _type == ItemTypeDirectory; }
bool isFile() const { return _type == ItemTypeFile || _type == ItemTypeVirtualFileDehydration; }
bool isVirtualFile() const { return _type == ItemTypeVirtualFile || _type == ItemTypeVirtualFileDownload; }
QString pathFromUtf8() const { return QString::fromUtf8(_path); }
QString e2eMangledNameFromUtf8() const { return QString::fromUtf8(_e2eMangledName); }

QByteArray _path;
quint64 _inode = 0;
Expand Down
6 changes: 3 additions & 3 deletions src/libsync/discovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.e2eMangledNameFromUtf8() << "/" << serverEntry.e2eMangledName;

if (_discoveryData->isRenamed(path._original)) {
qCDebug(lcDisco) << "Ignoring renamed";
Expand Down Expand Up @@ -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.pathFromUtf8();

if (_discoveryData->isRenamed(originalPath)) {
qCInfo(lcDisco, "folder already has a rename entry, skipping");
Expand Down Expand Up @@ -896,7 +896,7 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo(
dbError();
return;
}
const auto originalPath = QString::fromUtf8(base._path);
const auto originalPath = base.pathFromUtf8();

// Function to gradually check conditions for accepting a move-candidate
auto moveCheck = [&]() {
Expand Down
4 changes: 2 additions & 2 deletions src/libsync/syncengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.pathFromUtf8();
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.pathFromUtf8();
QFile::remove(localFile);
}
});
Expand Down
4 changes: 2 additions & 2 deletions src/libsync/syncfileitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.pathFromUtf8();
item->_inode = rec._inode;
item->_modtime = rec._modtime;
item->_type = rec._type;
Expand All @@ -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.e2eMangledNameFromUtf8();
item->_isEncrypted = rec._isE2eEncrypted;
return item;
}
Expand Down
2 changes: 1 addition & 1 deletion test/syncenginetestutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.pathFromUtf8());
auto &parentDir = findOrCreateDirs(result, components.parentDirComponents());
auto name = components.fileName();
auto &item = parentDir.children[name];
Expand Down

0 comments on commit 32d1f0e

Please sign in to comment.