diff --git a/latty.py b/latty.py index dfd6798..b29fc47 100644 --- a/latty.py +++ b/latty.py @@ -63,7 +63,6 @@ class CLData(): if result.returncode == 0: print(build_text + "[SUCCESS]") - threading.Timer(60 * 5, cleanup, [output_dir + unique_id]).start() compress_com = "gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.5 -dNOPAUSE -dQUIET -dBATCH -dPrinted=false -sOutputFile=outputs/" + unique_id + ".compressed.pdf outputs/" + unique_id + ".pdf" result = subprocess.run( @@ -72,9 +71,17 @@ class CLData(): text=True ) + threading.Timer(60 * 5, cleanup, [output_dir + unique_id]).start() + + output_file = unique_id + if result.returncode == 0: + output_file += ".compressed.pdf" + else: + output_file += ".pdf" + return (send_from_directory( output_dir, - unique_id + ".compressed.pdf", + output_file, attachment_filename=self.username.replace(" ", "") + "_CoverLetter.pdf", as_attachment=True ), None)