mirror of
https://github.com/tickstep/aliyunpan.git
synced 2025-01-23 14:32:14 +08:00
remove file locker
This commit is contained in:
parent
8fc8d9b6f7
commit
bd958fb8df
@ -23,7 +23,6 @@ import (
|
||||
"github.com/tickstep/aliyunpan/internal/log"
|
||||
"github.com/tickstep/aliyunpan/internal/taskframework"
|
||||
"github.com/tickstep/aliyunpan/internal/utils"
|
||||
"github.com/tickstep/aliyunpan/library/filelocker"
|
||||
"github.com/tickstep/aliyunpan/library/requester/transfer"
|
||||
"github.com/tickstep/library-go/converter"
|
||||
"github.com/tickstep/library-go/logger"
|
||||
@ -146,19 +145,19 @@ func CmdDownload() cli.Command {
|
||||
}
|
||||
|
||||
// 获取下载文件锁,保证下载操作单实例
|
||||
locker := filelocker.NewFileLocker(config.GetLockerDir() + "/aliyunpan-download")
|
||||
if e := filelocker.LockFile(locker, 0755, true, 5*time.Second); e != nil {
|
||||
logger.Verboseln(e)
|
||||
fmt.Println("本应用其他实例正在执行下载,请先停止或者等待其完成")
|
||||
return nil
|
||||
}
|
||||
//locker := filelocker.NewFileLocker(config.GetLockerDir() + "/aliyunpan-download")
|
||||
//if e := filelocker.LockFile(locker, 0755, true, 5*time.Second); e != nil {
|
||||
// logger.Verboseln(e)
|
||||
// fmt.Println("本应用其他实例正在执行下载,请先停止或者等待其完成")
|
||||
// return nil
|
||||
//}
|
||||
|
||||
RunDownload(c.Args(), do)
|
||||
|
||||
// 释放文件锁
|
||||
if locker != nil {
|
||||
filelocker.UnlockFile(locker)
|
||||
}
|
||||
//if locker != nil {
|
||||
// filelocker.UnlockFile(locker)
|
||||
//}
|
||||
return nil
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
|
@ -21,7 +21,6 @@ import (
|
||||
"github.com/tickstep/aliyunpan/internal/log"
|
||||
"github.com/tickstep/aliyunpan/internal/syncdrive"
|
||||
"github.com/tickstep/aliyunpan/internal/utils"
|
||||
"github.com/tickstep/aliyunpan/library/filelocker"
|
||||
"github.com/tickstep/library-go/converter"
|
||||
"github.com/tickstep/library-go/logger"
|
||||
"github.com/urfave/cli"
|
||||
@ -221,19 +220,19 @@ priority - 优先级,只对双向同步备份模式有效。选项支持三种
|
||||
}
|
||||
|
||||
// 获取同步文件锁,保证同步操作单实例
|
||||
locker := filelocker.NewFileLocker(config.GetLockerDir() + "/aliyunpan-sync")
|
||||
if e := filelocker.LockFile(locker, 0755, true, 5*time.Second); e != nil {
|
||||
logger.Verboseln(e)
|
||||
fmt.Println("本应用其他实例正在执行同步,请先停止或者等待其完成")
|
||||
return nil
|
||||
}
|
||||
//locker := filelocker.NewFileLocker(config.GetLockerDir() + "/aliyunpan-sync")
|
||||
//if e := filelocker.LockFile(locker, 0755, true, 5*time.Second); e != nil {
|
||||
// logger.Verboseln(e)
|
||||
// fmt.Println("本应用其他实例正在执行同步,请先停止或者等待其完成")
|
||||
// return nil
|
||||
//}
|
||||
|
||||
RunSync(task, dp, up, downloadBlockSize, uploadBlockSize, syncOpt, c.Int("ldt"), step)
|
||||
|
||||
// 释放文件锁
|
||||
if locker != nil {
|
||||
filelocker.UnlockFile(locker)
|
||||
}
|
||||
//if locker != nil {
|
||||
// filelocker.UnlockFile(locker)
|
||||
//}
|
||||
return nil
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
|
@ -20,7 +20,6 @@ import (
|
||||
"github.com/tickstep/aliyunpan/internal/log"
|
||||
"github.com/tickstep/aliyunpan/internal/plugins"
|
||||
"github.com/tickstep/aliyunpan/internal/utils"
|
||||
"github.com/tickstep/aliyunpan/library/filelocker"
|
||||
"github.com/tickstep/library-go/requester/rio/speeds"
|
||||
"os"
|
||||
"path"
|
||||
@ -179,12 +178,12 @@ func CmdUpload() cli.Command {
|
||||
}
|
||||
|
||||
// 获取上传文件锁,保证上传操作单实例
|
||||
locker := filelocker.NewFileLocker(config.GetLockerDir() + "/aliyunpan-upload")
|
||||
if e := filelocker.LockFile(locker, 0755, true, 5*time.Second); e != nil {
|
||||
logger.Verboseln(e)
|
||||
fmt.Println("本应用其他实例正在执行上传,请先停止或者等待其完成")
|
||||
return nil
|
||||
}
|
||||
//locker := filelocker.NewFileLocker(config.GetLockerDir() + "/aliyunpan-upload")
|
||||
//if e := filelocker.LockFile(locker, 0755, true, 5*time.Second); e != nil {
|
||||
// logger.Verboseln(e)
|
||||
// fmt.Println("本应用其他实例正在执行上传,请先停止或者等待其完成")
|
||||
// return nil
|
||||
//}
|
||||
|
||||
RunUpload(subArgs[:c.NArg()-1], subArgs[c.NArg()-1], &UploadOptions{
|
||||
AllParallel: c.Int("p"), // 多文件上传的时候,允许同时并行上传的文件数量
|
||||
@ -200,9 +199,9 @@ func CmdUpload() cli.Command {
|
||||
})
|
||||
|
||||
// 释放文件锁
|
||||
if locker != nil {
|
||||
filelocker.UnlockFile(locker)
|
||||
}
|
||||
//if locker != nil {
|
||||
// filelocker.UnlockFile(locker)
|
||||
//}
|
||||
return nil
|
||||
},
|
||||
Flags: UploadFlags,
|
||||
|
Loading…
Reference in New Issue
Block a user