Skip to content

Commit d72c64a

Browse files
authored
Merge pull request #1 from syscc/release/v0.0.2
release: v0.0.2 ensure recursive dst path creation for manual sync
2 parents d996b1c + b6e6969 commit d72c64a

2 files changed

Lines changed: 20 additions & 4 deletions

File tree

service/syncJob/jobClient.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,19 @@ def listDir(self, path, firstDst, spec, rootPath, isSrc=True):
430430
isPath=1)
431431
raise e
432432

433+
def ensurePath(self, path):
434+
if self.breakFlag:
435+
return
436+
scanInterval = self.job['scanIntervalT']
437+
segs = [s for s in path.split('/') if s]
438+
cur = '/'
439+
for s in segs:
440+
cur = cur + s + '/'
441+
try:
442+
self.alistClient.fileListApi(cur, 0, scanInterval, None, cur)
443+
except Exception:
444+
self.alistClient.mkdir(cur, scanInterval)
445+
433446
def syncWithHave(self, srcPath, dstPath, spec, srcRootPath, dstRootPath, firstDst):
434447
"""
435448
扫描并同步-目标目录存在目录(意味着要继续扫描目标目录)
@@ -445,9 +458,12 @@ def syncWithHave(self, srcPath, dstPath, spec, srcRootPath, dstRootPath, firstDs
445458
return
446459
try:
447460
srcFiles = self.listDir(srcPath, firstDst, spec, srcRootPath)
448-
dstFiles = self.listDir(dstPath, firstDst, spec, dstRootPath, False)
461+
try:
462+
dstFiles = self.listDir(dstPath, firstDst, spec, dstRootPath, False)
463+
except Exception:
464+
self.syncWithOutHave(srcPath, dstPath, spec, srcRootPath, dstRootPath, firstDst)
465+
return
449466
except Exception:
450-
# 已在listDir做出日志打印等操作,此处啥都不用做
451467
return
452468
for key in srcFiles.keys():
453469
# 如果是文件
@@ -486,7 +502,7 @@ def syncWithOutHave(self, srcPath, dstPath, spec, srcRootPath, dstRootPath, firs
486502
status = 2
487503
errMsg = None
488504
try:
489-
self.alistClient.mkdir(dstPath, self.job['scanIntervalT'])
505+
self.ensurePath(dstPath)
490506
except Exception as e:
491507
status = 7
492508
errMsg = str(e)

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
v0.0.1,latest
1+
v0.0.2,latest
22

33
# retrigger build at 2025-12-11 22:45
44

0 commit comments

Comments
 (0)