denis-stepanov/advent

Support for smart overwrite

Closed this issue · 1 comments

Current db-djv-pg export / import -o behavior is to delete the existing object of the same name at the target and create it again. Actually, both database and files know SHA1 hash of the object, so a bit smarter behavior would be to delete + create only if SHA1 hashes differ.

Summary of implementation:

  • default behavior does not change (no overwrite);
  • -o option now checks SHA1 of source and target and refuses overwrite if they match. Previous behavior was unconditional overwrite;
  • new -O option implements unconditional overwrite.

These options are implemented on commands export, import and rename. The latter works in both DB and file modes.