Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tmsu-fs-mv may overwrites files it cannot update internally #248

Open
Estecka opened this issue May 20, 2022 · 4 comments
Open

tmsu-fs-mv may overwrites files it cannot update internally #248

Estecka opened this issue May 20, 2022 · 4 comments

Comments

@Estecka
Copy link

Estecka commented May 20, 2022

Starting from this repository:

$ tmsu init;
$ echo beep >beep;
$ echo boop >boop;
$ tmsu tag beep beep;
tmsu:  new tag 'beep'
$ tmsu tag boop boop;
tmsu:  new tag 'boop'

If I attempt to move one file onto the other using tmsu-fs-mv, the command will fail, and not update the pathes in the database. However the actual files on the filesystem will still be overwritten.

$ tmsu-fs-mv boop beep
tmsu: UNIQUE constraint failed: file.directory, file.name
$ tmsu files
./beep
./boop
$ ls
beep
$ cat beep
boop

I have no reason to actually want this, but it may still happen on accident. Because tmsu also seems reticent to this, and this is a destructive operation, I would expect it to refrain from actually moving the files.

Alternatively, having a -n, --no-clobber option like for mv would be a welcome addition. This would prevent overwritting even files that are not registered in the database.

@oniony
Copy link
Owner

oniony commented May 20, 2022

TMSU itself has no filesystem operations, so it's never destructive. The script you're talking about is a convenience helper that may well have limitations.

To be frank I think the solution may be to just remove these scripts, because they're limited and if we're spending loads of effort getting these correct then we may as well spend the efort to have TMSU have this functionality built in. Except I find that idea distasteful.

I've never wanted TMSU to be able to write to the file system, other than its own database, so that a user can have confidence of TMSU's role in their filesystem.

@oniony
Copy link
Owner

oniony commented May 20, 2022

Having said all that, I think the actual problem here may be a bug in tmsu repair --manual. Reframed as such, it would be something that can be fixed.

@Estecka
Copy link
Author

Estecka commented May 20, 2022

They're definitely nice shorthands to have, but I see why you wouldn't want them built-in. I was even going to recreate them myself until I found out about the "native" ones. For now I'll just customize them directly. It just hadn't occurred to me that these were mere shell scripts, so I never thought about check their content.

Having said all that, I think the actual problem here may be a bug in tmsu repair --manual.

I think it's a good thing that repair fails in that scenario; I don't see what else it should be supposed to do. If I wanted to "merge" the files, I'd just use tag --from and untag --all instead.

@oniony
Copy link
Owner

oniony commented May 24, 2022

It should fail, but it should probably fail more gracefully than a database constraint violation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants