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