MCPcopy
hub / github.com/rclone/rclone / renewLockFile

Method renewLockFile

cmd/bisync/lockfile.go:77–94  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

75}
76
77func (b *bisyncRun) renewLockFile() {
78 if b.lockFile != "" && bilib.FileExists(b.lockFile) {
79
80 b.lockFileOpt.data.Session = b.basePath
81 b.lockFileOpt.data.PID = strconv.Itoa(os.Getpid())
82 b.lockFileOpt.data.TimeRenewed = time.Now()
83 b.lockFileOpt.data.TimeExpires = time.Now().Add(time.Duration(b.opt.MaxLock))
84
85 // save data file
86 df, err := os.Create(b.lockFile)
87 b.handleErr(b.lockFile, "error renewing lock file", err, true, true)
88 b.handleErr(b.lockFile, "error encoding JSON to lock file", json.NewEncoder(df).Encode(b.lockFileOpt.data), true, true)
89 b.handleErr(b.lockFile, "error closing lock file", df.Close(), true, true)
90 if b.opt.MaxLock < basicallyforever {
91 fs.Infof(nil, Color(terminal.HiBlueFg, "lock file renewed for %v. New expiration: %v"), b.opt.MaxLock, b.lockFileOpt.data.TimeExpires)
92 }
93 }
94}
95
96func (b *bisyncRun) lockFileIsExpired() bool {
97 if b.lockFile != "" && bilib.FileExists(b.lockFile) {

Callers 2

setLockFileMethod · 0.95
startLockRenewalMethod · 0.95

Calls 8

handleErrMethod · 0.95
FileExistsFunction · 0.92
InfofFunction · 0.92
ColorFunction · 0.85
AddMethod · 0.65
CreateMethod · 0.65
EncodeMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected