Skip to content

image.album can be null if image file previously deleted #9

@Libarch

Description

@Libarch

Hi, thanks for this excellent module which has already saved me loads of time.

Opening my Digikam database (digikam4.db) with sqliteman, I can see that the images table includes previously-deleted image files, with status set to 3 and album to null. These rows are included in lists returned by dk.images.all(). So for example, executing this code when some image files tagged with My tag have previously been updated will throw an AttributeError when the iteration reaches the first 'deleted' image:

dk = Digikam('digikamrc')
my_images = dk.tags['My tag'].images.all()
for i in my_images:
path_to_image = i.abspath
throws

Traceback (most recent call last):
File "<...>/test_ddb.py", line 17, in
path_to_image = i.abspath
^^^^^^^^^
File "<...>/.venv/lib64/python3.11/site-packages/digikamdb/images.py", line 444, in abspath
self.album.abspath,
^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'abspath'

Should there be something like an include-deleted (default = False) arg in the images.all() method to filter out these rows? Or specifically in the abspath call, a test for a null album attribute? In the meantime an easy workaround is to use

my_images = [i for i in dk.tags['My tag'].images if i.album]

instead of images.all()

Hope this makes sense

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions