oniony / TMSU

TMSU lets you tags your files and then access them through a nifty virtual filesystem from any other application.
Other
2.01k stars 115 forks source link

How can I delete values? #251

Closed TheChymera closed 2 years ago

TheChymera commented 2 years ago

There is no example given in tmsu help delete, though it says that there is a --value flag. tmsu delete mytag --value myvalue doesn't seem to work, it complains that there is not value called “mytag”.

oniony commented 2 years ago
tmsu delete --value somevalue someothervalue
0ion9 commented 2 years ago

a) it does work. you can verify this by using tmsu values before and after. b) tmsu delete mytag --value myvalue means the same thing as tmsu delete --value mytag myvalue -- delete the two values named mytag and myvalue c) your question implies an assumption that 'delete the X value of Y tag' is a valid operation, but in fact values do not 'belong to' tags; 'delete X value' is a valid operation, which means that all TAG=VALUE pairs where VALUE is X are removed from the database (in addition to removing the record that specifies the name of the value)

TheChymera commented 1 year ago

@0ion9 does this mean that if multiple tags have identical values (i.e. numerical values for ranking-type tags) tmsu delete good --value 1 will delete good=3 but also people=3 ? :-/

0ion9 commented 1 year ago

@TheChymera No and yes. The value 'good' - NOT the tag 'good' - will be deleted. Since you may not have a value 'good', this probably just generate a non-fatal error. TMSU will continue on and delete the other value you specified, '3' (actually you said 1 but I inferred from context you meant 3). All rows in file_tag referencing that value_id will be removed. This includes the tagging people=3, as the value_id is exactly the same (each value_id represents one unique name. Duplicate names are not allowed.)

The fact that you placed --value after good is irrelevant to TMSU. The presence of --value states that all non-option arguments are values that should be deleted. You either want a) to delete the tag good -tmsu delete good, b) to delete the value 3 - tmsu delete --value 3, or c) to remove all taggings good=3, while not deleting any tags or values : tmsu files -0 good=3 | xargs -0 tmsu untag -t good=3

Case c) is as complicated as it is because, unlike tmsu tag, tmsu untag doesn't have a -w / --where option. Otherwise it would be tmsu untag -w good=3 good=3. I think that would be a reasonable feature request.

Please read carefully. In particular, distinguishing between a tagging and a tag is critical. Some of this was already explained in my previous post.