reintroduce correct failure handling
This commit is contained in:
parent
3914546c92
commit
7b6ecf25ac
14
cleanmedia
14
cleanmedia
@ -59,15 +59,15 @@ class File:
|
|||||||
if self.fullpath is None:
|
if self.fullpath is None:
|
||||||
logging.info(f"No known path for file id '{self.media_id}', cannot delete file.")
|
logging.info(f"No known path for file id '{self.media_id}', cannot delete file.")
|
||||||
res = False
|
res = False
|
||||||
if not self.fullpath.is_dir():
|
elif not self.fullpath.is_dir():
|
||||||
logging.debug(f"Path for file id '{self.media_id}' is not a directory or does not exist, not deleting.")
|
logging.debug(f"Path for file id '{self.media_id}' is not a directory or does not exist, not deleting.")
|
||||||
res = False
|
res = False
|
||||||
|
else:
|
||||||
for file in self.fullpath.glob('*'):
|
for file in self.fullpath.glob('*'):
|
||||||
# note: this does not handle directories in fullpath
|
# note: this does not handle directories in fullpath
|
||||||
file.unlink()
|
file.unlink()
|
||||||
self.fullpath.rmdir()
|
self.fullpath.rmdir()
|
||||||
logging.debug(f"Deleted directory {self.fullpath}")
|
logging.debug(f"Deleted directory {self.fullpath}")
|
||||||
|
|
||||||
with self.repo.conn.cursor() as cur:
|
with self.repo.conn.cursor() as cur:
|
||||||
cur.execute("DELETE from mediaapi_thumbnail WHERE media_id=%s;", (self.media_id,))
|
cur.execute("DELETE from mediaapi_thumbnail WHERE media_id=%s;", (self.media_id,))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user