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

tmsu mount fails if database does not exist on default paths #239

Closed mpeter50 closed 2 years ago

mpeter50 commented 2 years ago

Tried running tmsu mount "/mnt/longpath/.tmsu/db" /mnt/longpath/mediumpath/mountags/, and it works if I run it from a subdir of the dir that contains the db, but if I run it from home, or try to mount the VFS with fstab, it fails with tmsu: no database found: use 'tmsu init' to create one, however, there is a database on the first path.

I don't know much about Go, but I think I found what is the problem.

In src/github.com/oniony/TMSU/cli/cli.go::Run(), it tries to find a database by the --database option, then by the TMSU_DB env var, and then by discovery, starting from the current working directory and going back to root. If it fails in it, it prints errors and sets databasePath to nil, which it gets from src/github.com/oniony/TMSU/cli/common.go::openDatabase(). Then, src/github.com/oniony/TMSU/cli/mount.go::mountExec() gets called with the nil databasePath, and since the openDatabase in it fails again, it won't get to reading the database path from the args, because it returns with the error right there.

It seems a workaround is having a database in the root directory, but I'm not sure if that's a good idea to do.

oniony commented 2 years ago

Have you tried mounting using the --database option?

mpeter50 commented 2 years ago

That way it works on the command line, but I can't put it into fstab :/ Unless if I put that into the mount helper script too.

oniony commented 2 years ago

Yes, it would make sense to add to helper script. If you get it working and submit PR I'll merge.

Thanks Paul

On Fri, 7 Jan 2022, 12:25 mpeter50, @.***> wrote:

That way it works on the command line, but I can't put it into fstab :/ Unless if I put that into the mount helper script too.

— Reply to this email directly, view it on GitHub https://github.com/oniony/TMSU/issues/239#issuecomment-1007367875, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAABOB5DCHVL7EL5DFVJ3PDUU3LTVANCNFSM5LMYK5ZA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you commented.Message ID: @.***>

mpeter50 commented 2 years ago

Ok, but before I do that, I would like to ask something. What was the original concept with the DB_PATH argument of the tmsu mount command?

I ask this mostly so I know if placing this in the mount helper script is a workaround or 'the way it's done'. Also, I if it is the latter, I would like to change the tmsu mount command's help documentation, so it doesn't show anymore that argument.

mpeter50 commented 2 years ago

I've made some changes to the mount helper script to fix this issue, and also changed the documentation shows by tmsu help mount.

Could you take a look please?

As you can see earlier I've modified the script so that it prints some information useful for debugging. I've put half of that behind a variable which disables it by default, but I've kept the --verbose option on the TMSU command, because I didn't find a way to make it conditional while keeping the script easy to follow. What do you think of that? Is it ok? Do you have a suggestion on how to change it? What I tried is moving the global options into a variable, that is modified at 2 places, and referencing that variable in the commands at the bottom, but I found it unnecessarily hard to follow.

mpeter50 commented 2 years ago

Oh, umm, pull request. I forgot that.