Clean up torrents before removing referenced storages

This commit is contained in:
Jake Moshenko 2016-01-12 11:43:07 -05:00
parent cbcb1da059
commit 96c72e73df

View file

@ -69,6 +69,12 @@ def garbage_collect_storage(storage_id_whitelist):
storage_id_whitelist,
(ImageStorage.id,)).alias('osq'))
if len(orphaned_storages) > 0:
torrents_removed = (TorrentInfo
.delete()
.where(TorrentInfo.storage << orphaned_storages)
.execute())
logger.debug('Removed %s torrent info records', torrents_removed)
storages_removed = (ImageStorage
.delete()
.where(ImageStorage.id << orphaned_storages)