From 97226674e70162d74d7d8c35293d25a2955940ac Mon Sep 17 00:00:00 2001 From: Davide Bongiovanni Date: Tue, 6 Jun 2017 23:56:21 +0200 Subject: [PATCH] Added file removal when substituting datasheet --- server.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server.py b/server.py index ef45901..3256716 100644 --- a/server.py +++ b/server.py @@ -1,5 +1,6 @@ -import json +import os import re +import json import sqlalchemy from sqlalchemy.sql import select from sqlalchemy.sql import text @@ -97,7 +98,7 @@ def alter(partID): datasheet_file = request.files['datasheet-file'] datasheet_filename = secure_filename(datasheet_file.filename) datasheet_file.save('/srv/datasheets/' + datasheet_filename) - # TODO: Remove old datasheet + os.remove('/srv/datasheets/' + l[0]['datasheet']) else: datasheet_filename = l[0]['datasheet'] s += 'where id=:id;'