nicoboss/nsz

Request Verify integrity of file

fennectech opened this issue · 2 comments

I would like a way to verify the integrity of (and delete failed) files

Just use the -V option. It that option is specified during compression it will skip failed ones and provides you a list after every file in the specified folder was processed containing all failures. If specified without the compress or decompress option every file in the specified folder well get verified (no matter if compressed or not) and for every failure a fatal exception will be thrown. If you understand some python it should be easy for you to replace that verification exception with an os.remove command. I hope I was able to help you. Please provide more information if this doesn't answer your question and otherwise close the issue.

  -V, --verify          Verifies files after compression raising an unhandled
                        exception on hash mismatch and verify existing NSP and
                        NSZ files when given as parameter

If you wonder how verification works basically every NCA file on the Nintendo Switch contains a unique SHA256 hash which is stored booth inside the file name and the Cnmt meta information. If not compressed it's just SHA256 hashing the NCA files and comparing that hash with the one stored in the meta information. If compressed it will decompress it and then verifies every NCAs integrity by comparing it's SHA256 hash. There is no way a successfully verified NCA would be corrupted. Keep in mind that there are some dirty game modifications out there that haven't changed the hash inside the meta information’s so such would fail verification so this method should only be used for clean unmodified games.