rcw-2 / python-digikamdb

Python library to access Digikam metadata
MIT License
11 stars 0 forks source link

`dk.image.find` not working on windows #3

Open raphaelquast opened 1 year ago

raphaelquast commented 1 year ago

Hey, First of all thanks a lot for this awesome tool!
I tried to use it to auto-tag a ton of images based on folder-names and it did the job really well!

I am on windows, so I can confirm that most of the image and tagging api works as expected.

The only issue I ran into so far is that the image.find function which seems to search for some linux-mounts?

Using ordinary indexing to access images works just fine (e.g. dk.image[10])

dk.image.find("some path")
>>>FileNotFoundError: [Errno 2] No such file or directory: '/proc/mounts'
rcw-2 commented 1 year ago

Hello Raphael,

Hey, First of all thanks a lot for this awesome tool! I tried to use it to auto-tag a ton of images based on folder-names and it did the job really well!

Thank you for the praise. ;-)

I am on windows, so I can confirm that most of the image and tagging api works as expected. The only issue I ran into so far is that the image.find function which seems to search for some linux-mounts?

Digikam usually stores the file system's UUID and a relative path in AlbumRoots to specify the directory. The code converts this to a path on Linux, but I cannot test how this works on Windows. You can try to get around this with the (hardly documented) root_override argument of the Digikam constructor, e.g.

dk = Digikam(
    "sqlite:///....",
    root_override = {"ids": {"<Identifier>": "<Path>"}}
)

Identifier ist the contents of AlbumRoots.identifier in the database (usually of the form "volumeid:?uuid=...") and Path the root directory of the volume (probably something like "C:\"). With this parameter, Digikam-DB will just use the given path and the error should not occur.

There may be additional issues as Digikam does case-sensitive compares and may miss some filename equalities.

Hope this helps you a step further...

rcw-2 commented 11 months ago

0.3.3 warns when trying to determine mountpoints on systems other than Linux. Anyway, it will probably just crash without the /dev/disk/... links. The documentation for the root_override parameter has also been updated. Python 3.12 has some function (listmounts, listvolumes) that may do the job, but I don't have the time to develop and test on other systems than Linux. If someone can provide a fix, I'll be glad to include it.