From 865a94e914dda2be165027202cc4fb4eb7b5c94a Mon Sep 17 00:00:00 2001 From: navyd Date: Fri, 19 Jul 2024 11:45:44 +0800 Subject: [PATCH 1/2] fix(sync): Config item media.min_filesize is not respected when transferring only --- app/sync.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/sync.py b/app/sync.py index 17250dae..16d3dc40 100644 --- a/app/sync.py +++ b/app/sync.py @@ -415,6 +415,10 @@ def __link(self, event_path, mon_path, target_path, sync_mode): """ if self.dbhelper.is_sync_in_history(event_path, target_path): return + ep_size = os.stat(event_path).st_size + if ep_size < self.filetransfer._min_filesize: + log.info("【Sync】跳过同步 %s size=%.2fMB" % (event_path, ep_size / (1024 * 1024))) + return log.info("【Sync】开始同步 %s" % event_path) try: ret, msg = self.filetransfer.link_sync_file(src_path=mon_path, From 3efbb453f6c18c79185f7764acdfa22c124de26f Mon Sep 17 00:00:00 2001 From: navyd Date: Fri, 19 Jul 2024 14:39:25 +0800 Subject: [PATCH 2/2] fix(sync): Fetch event file size too small when transferring links only --- app/sync.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/sync.py b/app/sync.py index 16d3dc40..1eac502f 100644 --- a/app/sync.py +++ b/app/sync.py @@ -1,5 +1,6 @@ import os import threading +import time import traceback from watchdog.events import FileSystemEventHandler @@ -415,7 +416,11 @@ def __link(self, event_path, mon_path, target_path, sync_mode): """ if self.dbhelper.is_sync_in_history(event_path, target_path): return - ep_size = os.stat(event_path).st_size + ep_size = 0 + # fix size to small: wait till copy finishes + while ep_size != (cur_size := os.stat(event_path).st_size): + ep_size = cur_size + time.sleep(1) if ep_size < self.filetransfer._min_filesize: log.info("【Sync】跳过同步 %s size=%.2fMB" % (event_path, ep_size / (1024 * 1024))) return