From 214d52d36f21e1d72851f3f9dbba6b77f1b3f79f Mon Sep 17 00:00:00 2001 From: msramalho <19508417+msramalho@users.noreply.github.com> Date: Wed, 23 Feb 2022 16:43:42 +0100 Subject: [PATCH] improved tmp folder management --- archivers/base_archiver.py | 3 ++- auto_archive.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/archivers/base_archiver.py b/archivers/base_archiver.py index dc47273..12cca80 100644 --- a/archivers/base_archiver.py +++ b/archivers/base_archiver.py @@ -1,6 +1,7 @@ import os import ffmpeg import datetime +import shutil from dataclasses import dataclass from abc import ABC, abstractmethod from urllib.parse import urlparse @@ -78,7 +79,6 @@ class Archiver(ABC): self.storage.upload(thumbnail_filename, key) cdn_urls.append(cdn_url) - os.remove(thumbnail_filename) if len(cdn_urls) == 0: return ('None', 'None') @@ -100,6 +100,7 @@ class Archiver(ABC): thumb_index = key_folder + 'index.html' self.storage.upload(index_fname, thumb_index, extra_args={'ACL': 'public-read', 'ContentType': 'text/html'}) + shutil.rmtree(thumbnails_folder) thumb_index_cdn_url = self.storage.get_cdn_url(thumb_index) diff --git a/auto_archive.py b/auto_archive.py index 472efd2..ce82ee1 100644 --- a/auto_archive.py +++ b/auto_archive.py @@ -2,6 +2,7 @@ import os import datetime import argparse import requests +import shutil import gspread from loguru import logger from dotenv import load_dotenv @@ -126,7 +127,7 @@ def main(): mkdir_if_not_exists('tmp') process_sheet(args.sheet) - + shutil.rmtree('tmp') if __name__ == '__main__': main()