DOI-USGS/sciencebasepy

replace_file() leaves stale checksum

tparker-usgs opened this issue · 1 comments

When SbSession.replace_file() updates an item, it leaves the checksum for the old file in place. It would be better for replace_file() to set the checksum to None.

The process I've used to replace a file, verify it was received correctly, and update the checksum in the item is:

  1. upload the new file and receive the temporary path back
  2. update ScienceBase item to reference the temporary path of the new file and set the checksum to None
  3. download the item JSON and receive the permanent path of the new file
  4. download the new file and compare the checksum of the received file to what was uploaded
  5. update the ScienceBase item with the correct checksum

I've implemented that workflow here:
https://code.chs.usgs.gov/tparker/sb-dynamic-data-update/-/blob/main/sb_update/filereplacer.py

ennsk commented

@tparker-usgs This has been fixed with the new version 2.0.5