picasa2digikam icon indicating copy to clipboard operation
picasa2digikam copied to clipboard

KeyError: '/dev/dm-0' in DigikamDb.__init__

Open joshuisken opened this issue 2 years ago • 2 comments

I'm trying to run with --photos_dir on a NFS-mounted drive, in my case '/mnt/Multimedia/photos'.

First I changed uuid.upper() to uuid.lower() in volume_uuid_to_mountpoints, since on ubuntu 22.04 LTS uuids are lowercase. Then /dev/dm-0 is returned... which is not a mount point but a device.

Since the mount point is really '/mnt/Multimedia', with 'photos' as a sub-directory, I do not get the rationale of doing this type of trick. Is it maybe that the mount point should be kept out of the digikam dbase? Since I would like to run digikam both on linux and windows and I can imagine that may cause problems, since the mount point may (will...) be different on various machines.

joshuisken avatar Aug 16 '23 14:08 joshuisken

I would like to run digikam both on linux and windows

Yeah that likely won't work with a shared database file ... though perhaps after understanding the situation, you could pull a little trick with a switch_to_windows.py and switch_to_linux.py script that updates your database file accordingly.


I don't know myself what the correct mount point would be in your case. But here's how you can figure the situation out:

  1. Create /mnt/Multimedia/photostest_linux and .../photostest_windows just to keep things simple and isolated. Put a single photo inside for testing.
  2. Open digiKam on the respective OS and point it to the respective directory. digikam4.db files should have been created now.
  3. Use SQLite Browser (a tool you can install on either OS or both) to open the two respective files and to inspect the AlbumRoots table. Note that all other tables will refer to the id column of this table, whereas the type, identifier and specificPath columns are then used to figure out the "real" path.

You could post the contents of your two AlbumRoots tables here. Presumably they're different, which is why it wouldn't work with both OSes simultaneously. Though the contents of the table are easy to swap with a script. And we can then inspect how /dev/dm-0 and/or /mnt/Multimedia are included there to figure out the correct mount point on Linux.

Philipp91 avatar Aug 17 '23 07:08 Philipp91

What I found out in the meantime, if I initially create digikam4.db using digikam on both linux and windows:

  • The tabel AlbumRoots has a single entry, which basically points to the directory with photos.
  • Besides identifier and specificPath, the value of caseSensitivity is different.
  • For the rest the database looks identical: in any case there seem no absolute paths present. So changing that entry would allow switching, but Iḿ little concerned about caseSensitivity.
        id label status type indentifier                                          specificPath            caseSensitivity
Linux:   1 photos   0     1  volumeid:?uuid=abf5b070-093c-4ca7-bc06-218bd8f24b4c /mnt/Multimedia/photos   2
Windows: 1 photos   0     1  volumeid:?path=M:/photos                            /                        1

For picasa2digikam I should maybe change the linux identifier into volumeid:?path=/mnt/Multimedia/photos and specificPath into /. I will give that a try.

In any case the current linux identifier points to /dev/dm-0:

$ ls -l /dev/disk/by-uuid/abf5b070-093c-4ca7-bc06-218bd8f24b4c 
lrwxrwxrwx 1 root root 10 Aug 14 21:00 /dev/disk/by-uuid/abf5b070-093c-4ca7-bc06-218bd8f24b4c -> ../../dm-0

For digikam an extra .ini file could make the AlbumRoots table more flexible w.r.t. different computers running it. I hope that this table is the only one which is machine/OS dependent.

In any case I would like to use a mysql/mariadb server for digikam instead of sqlite.

joshuisken avatar Aug 17 '23 10:08 joshuisken