mirror of
https://gitlab.com/SIGBUS/nyaa.git
synced 2024-12-22 09:50:00 +00:00
Make sure torrent backup directory exists before writing torrent
This commit is contained in:
parent
39230e1f39
commit
38a3ba277c
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -9,3 +9,4 @@ install/*
|
||||||
uwsgi.sock
|
uwsgi.sock
|
||||||
/test_torrent_batch
|
/test_torrent_batch
|
||||||
config.py
|
config.py
|
||||||
|
torrents
|
||||||
|
|
|
@ -599,10 +599,16 @@ def upload():
|
||||||
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
# Store the actual torrent file as well
|
||||||
torrent_file = form.torrent_file.data
|
torrent_file = form.torrent_file.data
|
||||||
if app.config.get('BACKUP_TORRENT_FOLDER'):
|
if app.config.get('BACKUP_TORRENT_FOLDER'):
|
||||||
torrent_file.seek(0, 0)
|
torrent_file.seek(0, 0)
|
||||||
torrent_path = os.path.join(app.config['BACKUP_TORRENT_FOLDER'], '{}.{}'.format(torrent.id, secure_filename(torrent_file.filename)))
|
|
||||||
|
torrent_dir = app.config['BACKUP_TORRENT_FOLDER']
|
||||||
|
if not os.path.exists(torrent_dir):
|
||||||
|
os.makedirs(torrent_dir)
|
||||||
|
|
||||||
|
torrent_path = os.path.join(torrent_dir, '{}.{}'.format(torrent.id, secure_filename(torrent_file.filename)))
|
||||||
torrent_file.save(torrent_path)
|
torrent_file.save(torrent_path)
|
||||||
torrent_file.close()
|
torrent_file.close()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue