updated delete method to attempt removal and procede on failure

still need a method to delete random files that get scattered in an attempted "conversion" attempt (these were left around when ffmpeg failed).
also need further excepts based on FileNotExistsError, PermissionError etc.
This commit is contained in:
Xevion
2019-12-24 23:52:23 -06:00
parent 2a7f13c1ff
commit 518d433172

View File

@@ -66,7 +66,11 @@ class YouTubeAudio(db.Model):
return data if noConvert else json.dumps(data)
def delete(self):
os.remove(os.path.join('app', 'sounds', 'youtube', self.filename))
path = os.path.join('app', 'sounds', 'youtube', self.filename)
try:
os.remove(path)
except:
print(f'[{self.id}] Could not delete relevant file "{path}".')
db.session.delete(self)
db.session.commit()