mirror of
https://github.com/tickstep/aliyunpan.git
synced 2025-01-23 14:32:14 +08:00
complete one time cycle mode
This commit is contained in:
parent
465d8fa4e9
commit
ebed4ff62f
2
go.mod
2
go.mod
@ -38,4 +38,4 @@ require (
|
||||
//replace github.com/boltdb/bolt => github.com/tickstep/bolt v1.3.4
|
||||
//replace github.com/tickstep/bolt => /Users/tickstep/Documents/Workspace/go/projects/bolt
|
||||
//replace github.com/tickstep/library-go => /Users/tickstep/Documents/Workspace/go/projects/library-go
|
||||
//replace github.com/tickstep/aliyunpan-api => /Users/tickstep/Documents/Workspace/go/projects/aliyunpan-api
|
||||
replace github.com/tickstep/aliyunpan-api => /Users/tickstep/Documents/Workspace/go/projects/aliyunpan-api
|
||||
|
@ -260,6 +260,11 @@ driveName - 网盘名称,backup(备份盘),resource(资源盘)
|
||||
Usage: "备份策略, 支持两种: exclusive(排他备份文件,目标目录多余的文件会被删除),increment(增量备份文件,目标目录多余的文件不会被删除)",
|
||||
Value: "increment",
|
||||
},
|
||||
//cli.StringFlag{
|
||||
// Name: "pri",
|
||||
// Usage: "同步优先级,只对sync模式有效。当网盘和本地存在同名文件,优先使用哪个,选项支持三种: time-时间优先,local-本地优先,pan-网盘优先",
|
||||
// Value: "time",
|
||||
//},
|
||||
cli.StringFlag{
|
||||
Name: "cycle",
|
||||
Usage: "备份周期, 支持两种: infinity(永久循环备份),onetime(只运行一次备份)",
|
||||
@ -372,10 +377,20 @@ func RunSync(defaultTask *syncdrive.SyncTask, cycleMode syncdrive.CycleMode, fil
|
||||
_, ok := os.LookupEnv("ALIYUNPAN_DOCKER")
|
||||
if ok {
|
||||
// in docker container
|
||||
// 使用休眠以节省CPU资源
|
||||
fmt.Println("本命令不会退出,程序正在以Docker的方式运行。如需退出请借助Docker提供的方式。")
|
||||
for {
|
||||
time.Sleep(60 * time.Second)
|
||||
if cycleMode == syncdrive.CycleInfiniteLoop {
|
||||
// 使用休眠以节省CPU资源
|
||||
fmt.Println("本命令不会退出,程序正在以Docker的方式运行。如需退出请借助Docker提供的方式。")
|
||||
for {
|
||||
time.Sleep(60 * time.Second)
|
||||
}
|
||||
} else {
|
||||
for {
|
||||
if syncMgr.IsAllTaskCompletely() {
|
||||
fmt.Println("所有备份任务已完成")
|
||||
break
|
||||
}
|
||||
time.Sleep(5 * time.Second)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if cycleMode == syncdrive.CycleInfiniteLoop {
|
||||
|
@ -108,17 +108,7 @@ func (t *SyncTask) String() string {
|
||||
mode = "备份云盘文件(下载)"
|
||||
}
|
||||
builder.WriteString("同步模式: " + mode + "\n")
|
||||
if t.Mode == SyncTwoWay {
|
||||
priority := "时间优先"
|
||||
if t.syncOption.SyncPriority == SyncPriorityLocalFirst {
|
||||
priority = "本地文件优先"
|
||||
} else if t.syncOption.SyncPriority == SyncPriorityPanFirst {
|
||||
priority = "网盘文件优先"
|
||||
} else {
|
||||
priority = "时间优先"
|
||||
}
|
||||
builder.WriteString("优先选项: " + priority + "\n")
|
||||
}
|
||||
|
||||
policy := ""
|
||||
if t.Policy == SyncPolicyExclusive {
|
||||
if t.Mode == Upload {
|
||||
@ -134,7 +124,25 @@ func (t *SyncTask) String() string {
|
||||
policy = "增量备份(只下载)"
|
||||
}
|
||||
}
|
||||
builder.WriteString("同步策略: " + policy + "\n")
|
||||
|
||||
if t.Mode == SyncTwoWay {
|
||||
priority := "时间优先"
|
||||
if t.syncOption.SyncPriority == SyncPriorityLocalFirst {
|
||||
priority = "本地文件优先"
|
||||
} else if t.syncOption.SyncPriority == SyncPriorityPanFirst {
|
||||
priority = "网盘文件优先"
|
||||
} else {
|
||||
priority = "时间优先"
|
||||
}
|
||||
builder.WriteString("同步策略: " + priority + "\n")
|
||||
} else {
|
||||
builder.WriteString("同步策略: " + policy + "\n")
|
||||
}
|
||||
cycleModeStr := "永久循环"
|
||||
if t.CycleModeType == CycleOneTime {
|
||||
cycleModeStr = "运行一次"
|
||||
}
|
||||
builder.WriteString("运行周期: " + cycleModeStr + "\n")
|
||||
builder.WriteString("本地目录: " + t.LocalFolderPath + "\n")
|
||||
builder.WriteString("云盘目录: " + t.PanFolderPath + "\n")
|
||||
driveName := "备份盘"
|
||||
@ -198,7 +206,6 @@ func (t *SyncTask) Start() error {
|
||||
|
||||
// setup sync db file
|
||||
t.setupDb()
|
||||
|
||||
if t.fileActionTaskManager == nil {
|
||||
t.fileActionTaskManager = NewFileActionTaskManager(t)
|
||||
}
|
||||
@ -237,7 +244,7 @@ func (t *SyncTask) Start() error {
|
||||
} else if t.Mode == Download {
|
||||
go t.scanPanFile(t.ctx)
|
||||
} else if t.Mode == SyncTwoWay {
|
||||
go t.scanLocalFile(t.ctx)
|
||||
return fmt.Errorf("异常:暂不支持该模式。")
|
||||
} else {
|
||||
return fmt.Errorf("异常:暂不支持该模式。")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user