dshoreman / nextshot

A simple tool for taking screenshots on Linux and sharing via Nextcloud

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add configurable overwrite defaults

dshoreman opened this issue · comments

Now that #50 is fixed so that duplicate uploads return a link, we could really do with a way of preventing Nextshot from overwriting existing files.

Nextcloud automatically overwrites, so we would need to ping the webdav API prior to sending the upload request. If a file exists with the same name, the user should be able to decide how to proceed.

Rename/overwrite/abort prompt is taken care of with #83, leaving only config/runtime args:

Config Option

There should be an option in nextshot.conf to define the default behaviour.
Something like overwrite=<action> could work, with possible values of:

  • overwrite=always - overwrite automatically without asking (previous behaviour)
  • overwrite=append - automatically append iterator/timestamp to the filename
  • overwrite=rename - never overwrite, ask for a new filename each time
  • overwrite=prompt - ask whether to overwrite or rename at runtime (current behaviour)
  • overwrite=cancel - always abort the upload(?)

The best option to set by default if the config isn't set would probably be prompt. The idea of Nextshot is to minimise interaction though, so perhaps always would be the better default here.

Runtime Args

While a config option should cover most cases, there should also be ways of overriding it on a case-by-case basis.

  • --no-overwrite would be useful if config is set to always
  • --overwrite could likewise be handy for bypassing prompts occasionally

How useful these would be though is questionable. Maybe skip them unless someone really wants it - the config option is still better than always overwriting without any choice in the matter.

Caveats

  • Appending to the filename automatically is good in theory, but in practice it's not so easy to implement. Extra care would need to be taken to avoid somefile-1-1-1-1-1.png or bumping to somefile-2.png only to find that also exists. Possibly leave this option for a later release.
  • Aborting upload really isn't the most useful option, so that can probably be ignored.