Skip to content

Commit

Permalink
check for 20M min, and adds upload accel
Browse files Browse the repository at this point in the history
  • Loading branch information
jheld committed Sep 14, 2023
1 parent d46b6e1 commit 4a56879
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion diycrate/file_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
)
Expand All @@ -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
Expand Down Expand Up @@ -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(),
)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 4a56879

Please sign in to comment.