forked from kenzuya/unshackle
fix(attachment): keep custom fonts after mux cleanup
Attachment.delete() now removes a file only when it is in the temp directory, so fonts attached from the custom fonts directory survive.
This commit is contained in:
@@ -154,8 +154,9 @@ class Attachment:
|
||||
return hex(checksum)
|
||||
|
||||
def delete(self) -> None:
|
||||
if self.path and self.path.exists():
|
||||
self.path.unlink()
|
||||
"""Delete the file only if it is in the temp directory. Files in other locations belong to the user."""
|
||||
if self.path and self.path.is_relative_to(config.directories.temp):
|
||||
self.path.unlink(missing_ok=True)
|
||||
self.path = None
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -1003,8 +1003,7 @@ class Tracks:
|
||||
for track in self:
|
||||
track.delete()
|
||||
for attachment in self.attachments:
|
||||
if attachment.path and attachment.path.exists():
|
||||
attachment.path.unlink()
|
||||
attachment.delete()
|
||||
|
||||
|
||||
__all__ = ("Tracks",)
|
||||
|
||||
Reference in New Issue
Block a user