From bd958fb8df59cd3a6efbf4daaafdb0d1995d4507 Mon Sep 17 00:00:00 2001 From: tickstep Date: Tue, 27 Dec 2022 18:58:49 +0800 Subject: [PATCH] remove file locker --- internal/command/download.go | 19 +++++++++---------- internal/command/sync.go | 19 +++++++++---------- internal/command/upload.go | 19 +++++++++---------- 3 files changed, 27 insertions(+), 30 deletions(-) diff --git a/internal/command/download.go b/internal/command/download.go index 37e1ee1..fcb9135 100644 --- a/internal/command/download.go +++ b/internal/command/download.go @@ -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{ diff --git a/internal/command/sync.go b/internal/command/sync.go index 1382c62..3dab753 100644 --- a/internal/command/sync.go +++ b/internal/command/sync.go @@ -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{ diff --git a/internal/command/upload.go b/internal/command/upload.go index 0478319..8b41d92 100644 --- a/internal/command/upload.go +++ b/internal/command/upload.go @@ -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,