Garmelon/PFERD

Add an option to keep/backup old files after overwrite/update

Mr-Pine opened this issue · 2 comments

Feature

I would like an option to keep the old version of a file when the file is overwritten due to a change of the remote.

Reason

If you depend on a specific version of a file and update the file unknowingly (either using on_conflict: no-delete or not knowing the new version will break things) there is currently no possibility to retrieve the old version.

Alternatives

Adding a on_conflict option similar to no-delete that promts you when overwriting files would solve the issue that files might be updated unintentionally. This would let the user do manually what this feature would do for them.

How it could work

There would be a new crawler option called keep_backups
When it would be enabled and there is an incoming change from the remote, pferd would rename the local file to <filename>.pferdbackup.<extension> (keeping the original extension for Windows support) before saving the new version. I think one backed up version (so if a third option appears on the remote the backup file would contain the second version) would be enough since the user could check whether they need the old version when the change appears in the report.

Further ideas

  • (Optionally) keeping all (or a user set number of) versions of updated files in a separate folder (not the pferd output directory)
  • ...

Adding a on_conflict option similar to no-delete that promts you when overwriting files would solve the issue that files might be updated unintentionally. This would let the user do manually what this feature would do for them.

Isn't that what on_conflict = prompt does (the default value for on_conflict)?

I have my crawlers set to on_conflict = prompt. If I'm interested in what the change was, I diff the old version of a file (e. g. foo/bar.baz against the new version (e. g. foo/.bar/baz.tmp.wsho3k) before answering the prompt. To keep the old version, just copy it somewhere else before answering the prompt.

Prompt also prompts for deletions which can be a bit annoying if you have many files not present in ILIAS (see e.g. #65). This might happen when you unzip files or start to solve exercises in a synchronized folder from what I gathered.

EDIT: And you have to read carefully whether it prompts for deletion or overwriting