Closed frankenjoe closed 3 months ago
Maybe we can check what other applications do if the checksum does not match.
As we plan to make the check optional, the third option of raising an error seems a good solution to me. When a user opts in for checking MD5 sums, it should not silently continue if a sum does not match. If the user wants to add custom handling of those cases, she can do it with a try
-except
statement. This seems easier to me, than having to deal with different return types.
Option 3. makes most sense to me, too. To not overcomplicate we can leave it to the user to catch the error and possibly retry the operation. Regarding the error type we could raise a InterruptedError
or do you think we should introduce a custom error type?
No, using an existing type seems to me the better option.
Implemented in #190
To validate the upload of file to the backend I currently do:
Likewise, we can validate the download of a file:
I think it makes sense to move such a check into the functions. Since it comes with an additional cost of calculating the checksum for source and destination file (in case of
put_file()
we already already calculate the checksum of the source file) we could make it an optional step.In case of a mismatch of the checksum, it makes sense to remove the file. But what should we do next:
put_file()
does not have a return value yet, so we could e.g. return a boolean;get_file()
currently returns the full path to the local file, so here we have to returnNone
. To avoid different return types, we could return the full path of the source file in case ofput_file()
and alsoNone
in case of a failure.A fourth option would be to retry the operation first and only if it fails again fall back to one of 1.-3.