Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix file sizes in the data tab (WIP) #1453

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 4 additions & 16 deletions src/filetreeitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -243,7 +243,6 @@ class FileTreeItem
{
std::optional<T> value;
bool failed = false;
bool overridden = false;

bool empty() const
{
Expand All @@ -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;
}
};

Expand Down
12 changes: 11 additions & 1 deletion src/shared/directoryentry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
}

Expand Down