From 4a56879aeb6aff364127913ea5d345c1169acd78 Mon Sep 17 00:00:00 2001 From: Jason Held Date: Wed, 13 Sep 2023 22:31:26 -0400 Subject: [PATCH] check for 20M min, and adds upload accel --- diycrate/file_operations.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/diycrate/file_operations.py b/diycrate/file_operations.py index 2d4c2aa..7eace12 100644 --- a/diycrate/file_operations.py +++ b/diycrate/file_operations.py @@ -298,6 +298,8 @@ def process_real_close_event(self, event: pyinotify.Event): .timestamp() ) try: + if file_path.stat().st_size < 20000000: + raise BoxAPIException(code="file_size_too_small", status=400) box_uploader: ChunkedUploader = cur_box_folder.get_chunked_uploader( file_path.as_posix() ) @@ -311,6 +313,7 @@ def process_real_close_event(self, event: pyinotify.Event): file_path.as_posix(), file_path.name, preflight_check=True, + upload_using_accelerator=True, ) else: raise @@ -475,7 +478,13 @@ def process_modify_event(self, event: pyinotify.Event, operation: str): datetime.fromtimestamp(last_modified_time) .astimezone(dateutil.tz.tzutc()) .timestamp(), - partial(cur_box_folder.upload, file_path.as_posix(), file_path.name), + partial( + cur_box_folder.upload, + file_path.as_posix(), + file_path.name, + preflight_check=True, + upload_using_accelerator=True, + ), self.oauth, file_path.as_posix(), ) @@ -602,6 +611,8 @@ def process_create_event(self, event: pyinotify.Event): cur_box_folder.upload, event.pathname, os.path.basename(event.pathname), + preflight_check=True, + upload_using_accelerator=True, ), self.oauth, event.pathname, @@ -936,6 +947,8 @@ def and_after(): cur_box_folder.upload, dest_event.pathname, os.path.basename(dest_event.pathname), + preflight_check=True, + upload_using_accelerator=True, ), self.oauth, dest_event.pathname,