TMSU icon indicating copy to clipboard operation
TMSU copied to clipboard

Don't create new tags if file doesn't exist

Open ghost opened this issue 9 years ago • 3 comments

Steps to reproduce:

$ mkdir test
$ cd test
$ tmsu init
tmsu: /home/fturco/test: creating database
$ tmsu tag foo a b c
tmsu: new tag 'a'
tmsu: new tag 'b'
tmsu: new tag 'c'
tmsu: foo: no such file
$ tmsu tags
a  b  c

File foo doesn't exist, but tags a, b and c are created anyway. In my opinion that should not happen. TMSU should first check if file foo exists, and only in that case add tags to the database.

I'm using the latest git version of tmsu on a Gentoo Linux system.

ghost avatar Nov 30 '16 10:11 ghost

Thanks for reporting this.

I agree that it should probably not create the tags is this situation. However, what do you think TMSU should do in the case where multiple files are being tagged and only some of them exist? Currently the missing files are reported as warnings and the rest of the operation succeeds.

What about permission errors, should these be handled the same as missing files?

oniony avatar Nov 30 '16 10:11 oniony

The following command should create tags a, b and c if at least one of foo or bar exists:

tmsu tag foo bar --tags="a b c"

As you said this seems to be already implemented correctly.

If a file cannot be read and its checksum cannot be determined then it should be treated as a non-existing file in my opinion. Of course the warning message should be customized.

ghost avatar Nov 30 '16 11:11 ghost

The following command should create tags a, b and c if at least one of foo or bar > exists:

tmsu tag foo bar --tags="a b c"

👍 Seems fairly easy to understand. "new tags shall be created IFF there is at least one existing file they would ultimately be applied to"

If a file cannot be read and its checksum cannot be determined then it should be treated as a non-existing file in my opinion.

Fair enough for symlinks and ordinary files. FIFOs, sockets and devices may need special treatment (I don't know if anyone is tagging them, but we should decide on a policy for how they will be treated, if there isn't already). In general reading from FIFOs/sockets/devices may have undesirable side effects, so treating them as valid but not fingerprintable (like directories are by default) seems reasonable.

If a file cannot be read and its checksum cannot be determined then it should be treated as a non-existing file in my opinion. Of course the warning message should be customized.

👍 We should indicate all three conditions separately, IMO:

  • Lack of read permissions
  • File cannot be checksummed for other reasons (ie. permissions are fine but.. i/o error etc)
  • Symlink pointing to a non-existent destination.

0ion9 avatar Dec 18 '16 02:12 0ion9