@@ -403,7 +403,7 @@ def delFile(self, path, fileName, size):
403403 errMsg = str (e )
404404 self .delHook (path , fileName , None if isPath else size , status , errMsg , isPath , createTime )
405405
406- def listDir (self , path , firstDst , spec , rootPath , isSrc = True ):
406+ def listDir (self , path , firstDst , spec , rootPath , isSrc = True , ignoreError = False ):
407407 """
408408 列出目录
409409 self.job['useCacheT']: 扫描目标目录时,是否使用缓存,0-不使用,1-使用
@@ -415,13 +415,16 @@ def listDir(self, path, firstDst, spec, rootPath, isSrc=True):
415415 :param spec:
416416 :param rootPath:
417417 :param isSrc:
418+ :param ignoreError: 是否忽略错误(不记录日志和回调)
418419 :return:
419420 """
420421 useCache = 1 if isSrc and not firstDst else self .job [f"useCache{ 'S' if isSrc else 'T' } " ]
421422 scanInterval = self .job [f"scanInterval{ 'S' if isSrc else 'T' } " ]
422423 try :
423424 return self .openlistClient .fileListApi (path , useCache , scanInterval , spec , rootPath )
424425 except Exception as e :
426+ if ignoreError :
427+ raise e
425428 logger = logging .getLogger ()
426429 errMsg = G ('scan_error' ).format (G ('src' if isSrc else 'dst' ), str (e ))
427430 logger .error (errMsg )
@@ -441,7 +444,12 @@ def ensurePath(self, path):
441444 try :
442445 self .openlistClient .fileListApi (cur , 0 , scanInterval , None , cur )
443446 except Exception :
444- self .openlistClient .mkdir (cur , scanInterval )
447+ try :
448+ self .openlistClient .mkdir (cur , scanInterval )
449+ except Exception as e :
450+ logger = logging .getLogger ()
451+ logger .error (f"Failed to mkdir: { cur } , error: { str (e )} " )
452+ raise e
445453
446454 def syncWithHave (self , srcPath , dstPath , spec , srcRootPath , dstRootPath , firstDst ):
447455 """
@@ -459,7 +467,7 @@ def syncWithHave(self, srcPath, dstPath, spec, srcRootPath, dstRootPath, firstDs
459467 try :
460468 srcFiles = self .listDir (srcPath , firstDst , spec , srcRootPath )
461469 try :
462- dstFiles = self .listDir (dstPath , firstDst , spec , dstRootPath , False )
470+ dstFiles = self .listDir (dstPath , firstDst , spec , dstRootPath , False , ignoreError = True )
463471 except Exception :
464472 self .syncWithOutHave (srcPath , dstPath , spec , srcRootPath , dstRootPath , firstDst )
465473 return
@@ -506,6 +514,8 @@ def syncWithOutHave(self, srcPath, dstPath, spec, srcRootPath, dstRootPath, firs
506514 except Exception as e :
507515 status = 7
508516 errMsg = str (e )
517+ logger = logging .getLogger ()
518+ logger .error (f"SyncWithOutHave ensurePath failed: { dstPath } , error: { errMsg } " )
509519 # 目录回调
510520 self .copyHook (srcPath , dstPath , None , None , status = status , errMsg = errMsg , isPath = 1 )
511521 if status != 2 :
0 commit comments