Check (attributes) file when using --update flag#177
Open
sjoblomj wants to merge 2 commits into
Open
Conversation
ebd0d0b to
eb30dad
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
--updateflag for theaddsubcommand 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
--updateflag should be removed altogether. We can delegate the decision of whether to add a file to the archive to the user itself.