Delete db entries too
This commit is contained in:
parent
8410389d6a
commit
be6da99c1c
11
cleanmedia
11
cleanmedia
@ -77,7 +77,12 @@ class File:
|
|||||||
file.unlink()
|
file.unlink()
|
||||||
self.fullpath().rmdir()
|
self.fullpath().rmdir()
|
||||||
logging.debug(f"Deleted directory {self.fullpath()}")
|
logging.debug(f"Deleted directory {self.fullpath()}")
|
||||||
#delete directory (self.fullpath())
|
with self.repo.conn.cursor() as cur:
|
||||||
|
cur.execute(f"DELETE from mediaapi_thumbnail WHERE media_id='%s';", self.media_id)
|
||||||
|
num_thumbnails = cur.rowcount
|
||||||
|
cur.execute(f"DELETE from mediaapi_media_repository WHERE media_id='%s';", self.media_id)
|
||||||
|
num_media = cur.rowcount
|
||||||
|
logging.debug(f"Deleted {num_media} + {num_thumbnails} db entries for media id {self.media_id}")
|
||||||
|
|
||||||
def exists(self):
|
def exists(self):
|
||||||
"""returns True if the media file itself exists on the file system"""
|
"""returns True if the media file itself exists on the file system"""
|
||||||
@ -87,9 +92,9 @@ class File:
|
|||||||
return (path / 'file').exists()
|
return (path / 'file').exists()
|
||||||
|
|
||||||
def has_thumbnail(self):
|
def has_thumbnail(self):
|
||||||
cur = self.repo.conn.cursor()
|
with self.repo.conn.cursor() as cur:
|
||||||
# media_id | media_origin | content_type | file_size_bytes | creation_ts | upload_name | base64hash | user_id
|
# media_id | media_origin | content_type | file_size_bytes | creation_ts | upload_name | base64hash | user_id
|
||||||
res = cur.execute(f"select COUNT(media_id) from mediaapi_thumbnail WHERE media_id='{self.media_id}';")
|
cur.execute(f"select COUNT(media_id) from mediaapi_thumbnail WHERE media_id='{self.media_id}';")
|
||||||
row = cur.fetchone()
|
row = cur.fetchone()
|
||||||
return(row[0])
|
return(row[0])
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user