Closed 030 closed 5 years ago
I agree, this error should be returned. Fixed this in c709a70. Please let me know if you can now see why your file was not deleted.
@cavaliercoder An error message is returned now!
2018/11/08 07:25:08 cannot remove downloaded file with checksum mismatch: remove
C:\Program Files\someFolder\someZip.zip:
The process cannot access the file because it is being used by another process.
exit status 1
Apart from this, the file can be removed manually. Is the code preventing this or is this a Windows issue? I have ran the same command from an Administrator prompt, but then the same issue occurs.
When rm "/c/Program Files/someFolder\someZip.zip"
is issued the file gets removed immediately.
This may be because grab tries to delete the file before closing it (which does not manifest as an issue on Linux). I've refactored to ensure the file is first closed (see: 2c8601d).
Please test and advise.
@030 Any luck with this?
@cavaliercoder Verified that it works! Thank you! 👍
$ go run main_windows_amd64.go
2018/11/13 07:20:20 checksum mismatch
exit status 1
Steps to reproduce
Thanks for the feedback :)
Although there is a checksum mismatch, the file will not be removed:
Apart from this, how to prevent that the file gets downloaded anyway if there is checksum mismatch?
I think that one of the first improvements could be adding error handling to the os.remove snippet https://github.com/cavaliercoder/grab/blob/925bcfe56bc16868f1a398af4231cd4ffa07276f/client.go#L294 to ensure that at least an error message is returned. In my opinion error message should not be omitted.