Skip to content

Check (attributes) file when using --update flag#177

Open
sjoblomj wants to merge 2 commits into
thegraydot:mainfrom
sjoblomj:attributes-check
Open

Check (attributes) file when using --update flag#177
sjoblomj wants to merge 2 commits into
thegraydot:mainfrom
sjoblomj:attributes-check

Conversation

@sjoblomj

@sjoblomj sjoblomj commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

The --update flag for the add subcommand intends to only add the files if the local file is deemed "updated" compared to the file in the archive. A file is currently considered "updated" when the file sizes aren't equal.

However, as issue #174 points out, files can be updated yet still have the same file size. This is not uncommon - some of the files that mods for StarCraft I and WarCraft II change most often always have fixed sizes.

While not mandatory, some MPQ archives contains an (attributes) file, which can contain MD5 sums, CRC32 checksums and timestamps of the files inside the archives.

This PR will check the file sizes, and if they are the same it proceeds to check against the values of (attributes) if present. It compares the MD5 if present, if not it checks the CRC32 if present, if not it checks the timestamp. If any of these checks fail or if the values are not present, it considers the file "updated" and will thus attempt to re-add it.


The code for CRC32 and MD5 was written by AI and is by its nature quite messy to read. We need to ask ourselves if this is complexity we want in mpqcli. I myself am somewhat leaning towards answering No to that question - and I'd then say that the --update flag should be removed altogether. We can delegate the decision of whether to add a file to the archive to the user itself.

@sjoblomj sjoblomj force-pushed the attributes-check branch from ebd0d0b to eb30dad Compare July 8, 2026 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant