Fix yielded pathclass of purge_deleted_associated_directories.

This commit is contained in:
voussoir 2021-08-25 21:41:53 -07:00
parent e9d5711f29
commit 071b290fe6
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB

View file

@ -134,13 +134,13 @@ class PDBAlbumMixin:
def purge_deleted_associated_directories(self, albums=None): def purge_deleted_associated_directories(self, albums=None):
directories = self.sql_select('SELECT DISTINCT directory FROM album_associated_directories') directories = self.sql_select('SELECT DISTINCT directory FROM album_associated_directories')
directories = (pathclass.Path(directory) for (directory,) in directories) directories = (pathclass.Path(directory) for (directory,) in directories)
directories = [directory.absolute_path for directory in directories if not directory.exists] directories = [directory for directory in directories if not directory.is_dir]
if not directories: if not directories:
return return
self.log.info('Purging associated directories %s.', directories) self.log.info('Purging associated directories %s.', directories)
directories = sqlhelpers.listify(directories)
query = f'DELETE FROM album_associated_directories WHERE directory in {directories}' d_query = sqlhelpers.listify(directory.absolute_path for directory in directories)
query = f'DELETE FROM album_associated_directories WHERE directory in {d_query}'
if albums is not None: if albums is not None:
album_ids = sqlhelpers.listify(a.id for a in albums) album_ids = sqlhelpers.listify(a.id for a in albums)
query += f' AND albumid IN {album_ids}' query += f' AND albumid IN {album_ids}'