mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 17:25:44 +00:00
18 lines
532 B
Python
18 lines
532 B
Python
|
from ..decorators import background
|
||
|
from ..models import Result
|
||
|
import os
|
||
|
import shutil
|
||
|
|
||
|
|
||
|
@background
|
||
|
def delete_result(result_id, *args, **kwargs):
|
||
|
app = kwargs['app']
|
||
|
with app.app_context():
|
||
|
result = Result.query.get(result_id)
|
||
|
if result is None:
|
||
|
return
|
||
|
result_file_path = os.path.join(app.config['NOPAQUE_STORAGE'],
|
||
|
result.file[0].dir)
|
||
|
shutil.rmtree(result_file_path)
|
||
|
result.delete() # cascades down and also deletes ResultFile
|