From 7fef29d00f1305477aa91d6ab42fb163e848f3c1 Mon Sep 17 00:00:00 2001 From: Seth Ladygo Date: Thu, 12 Mar 2020 15:38:42 -0700 Subject: [PATCH] markup: delete any preexisting xls before processing --- markup/tasks.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/markup/tasks.py b/markup/tasks.py index de01024..252fe5e 100644 --- a/markup/tasks.py +++ b/markup/tasks.py @@ -72,6 +72,11 @@ def process_markup_pdf(pdf_path, username): print(f'No pdf - exiting ({pdf_path})') return + dest_xls_path = dest_spreadsheet_path(pdf_path) + if os.path.isfile(dest_xls_path): + print(f'deleting preexisting xls {dest_xls_path}') + os.remove(dest_xls_path) + user = User.objects.get(username=username) work_dir = workdir(user.username, pdf_path) @@ -105,8 +110,6 @@ def process_markup_pdf(pdf_path, username): print(f'error creating spreadsheet') return - dest_xls_path = dest_spreadsheet_path(pdf_path) - print(f'wrote spreadsheet: {work_xls_path}') print(f'copying xls to {dest_xls_path}')