A corrupt file will throw an error and produce a non-zero return code on any attempt to decompress it, so you may as well just try to decompress the thing into a temporary location. If the return code is zero then the archive was intact and you can move the files to their permanent home. If not, discard the files that might have been extracted before the corruption was detected. There is no point in decompressing the file twice, which is effectively what would happen if you tried to test it first. It will be tested anyway.