mirror of
https://gitlab.com/SIGBUS/nyaa.git
synced 2024-12-22 09:50:00 +00:00
Delete cached torrent file when replacing torrent.
This commit is contained in:
parent
602d35bab7
commit
1c3724cae1
|
@ -51,6 +51,7 @@ def handle_torrent_upload(upload_form, uploading_user=None, fromAPI=False):
|
||||||
if torrent_data.db_id is not None:
|
if torrent_data.db_id is not None:
|
||||||
models.Torrent.query.filter_by(id=torrent_data.db_id).delete()
|
models.Torrent.query.filter_by(id=torrent_data.db_id).delete()
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
_delete_cached_torrent_file(torrent_data.db_id)
|
||||||
|
|
||||||
# The torrent has been validated and is safe to access with ['foo'] etc - all relevant
|
# The torrent has been validated and is safe to access with ['foo'] etc - all relevant
|
||||||
# keys and values have been checked for (see UploadForm in forms.py for details)
|
# keys and values have been checked for (see UploadForm in forms.py for details)
|
||||||
|
@ -235,3 +236,11 @@ def tracker_api(info_hashes, method):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return req.status == 200
|
return req.status == 200
|
||||||
|
|
||||||
|
|
||||||
|
def _delete_cached_torrent_file(torrent_id):
|
||||||
|
# Note: obviously temporary
|
||||||
|
cached_torrent = os.path.join(app.config['BASE_DIR'],
|
||||||
|
'torrent_cache', str(torrent_id) + '.torrent')
|
||||||
|
if os.path.exists(cached_torrent):
|
||||||
|
os.remove(cached_torrent)
|
||||||
|
|
Loading…
Reference in a new issue