diff --git a/src/filetreeitem.h b/src/filetreeitem.h index 750e4719f..4c4bea4b3 100644 --- a/src/filetreeitem.h +++ b/src/filetreeitem.h @@ -150,12 +150,12 @@ class FileTreeItem void setFileSize(uint64_t size) { - m_fileSize.override(size); + m_fileSize.set(size); } void setCompressedFileSize(uint64_t compressedSize) { - m_compressedFileSize.override(compressedSize); + m_compressedFileSize.set(compressedSize); } const QString& realPath() const @@ -243,7 +243,6 @@ class FileTreeItem { std::optional value; bool failed = false; - bool overridden = false; bool empty() const { @@ -254,29 +253,18 @@ class FileTreeItem { value = std::move(t); failed = false; - overridden = false; - } - - void override(T t) - { - value = std::move(t); - failed = false; - overridden = true; } void fail() { value = {}; failed = true; - overridden = false; } void reset() { - if (!overridden) { - value = {}; - failed = false; - } + value = {}; + failed = false; } }; diff --git a/src/shared/directoryentry.cpp b/src/shared/directoryentry.cpp index badb56362..74b760ab5 100644 --- a/src/shared/directoryentry.cpp +++ b/src/shared/directoryentry.cpp @@ -675,7 +675,17 @@ void DirectoryEntry::onDirectoryEnd(Context* cx, std::wstring_view path) void DirectoryEntry::onFile(Context* cx, std::wstring_view path, FILETIME ft) { elapsed(cx->stats.fileTimes, [&]{ - cx->current.top()->insert(path, cx->origin, ft, L"", -1, cx->stats); + auto f = cx->current.top()->insert(path, cx->origin, ft, L"", -1, cx->stats); + + if (f) { + // the file might already be in the register and it might have come from + // an archive, which sets the file size if it's available (see addFiles() + // just below) + // + // so the file size might be stale here because the file is being + // overridden by another mod, make sure to clear it + f->setFileSize(FileEntry::NoFileSize, FileEntry::NoFileSize); + } }); }