Does lock.Refresh() actually prevent locks going stale?

Please pardon newbie question, but …

Reading latest source it appears to me that lock.Refresh() creates a new lock file in the backend but does not update the Lock.Time timestamp that is then serialized into that new file. Nor does cmd/restic/lock.go:refreshLocks() update it before calling lock.Refresh().

It seems to me that if an operation took longer than 30 minutes, even though the restic command calls lock.Refresh every 5 minutes, lock.Stale() would return true and the lock could be removed by a restic unlock even without the --remove-all flag.

Am I missing something (like the backend updating the Time value in the json)?

Hello @ewhamilton,

I haven’t looked at the code, but your analysis would explain why I messed a backup recently by running restic unlock before it finished, see here.

Cheers,
– Durval.