diff options
author | HimbeerserverDE <himbeerserverde@gmail.com> | 2021-09-13 17:31:04 +0200 |
---|---|---|
committer | HimbeerserverDE <himbeerserverde@gmail.com> | 2021-09-13 17:31:04 +0200 |
commit | 12b0d68687caf310674404e7ebd11b313a41fcff (patch) | |
tree | 035e244e376fa300cf8ad7c4c10080ccbcd86832 /auth_files.go | |
parent | 274a12246549efa002bcfc8ee9e0738e2730649c (diff) |
Fix file auth timestamp updater
Diffstat (limited to 'auth_files.go')
-rw-r--r-- | auth_files.go | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/auth_files.go b/auth_files.go index 22b1e60..78adbac 100644 --- a/auth_files.go +++ b/auth_files.go @@ -188,6 +188,22 @@ func (a authFiles) ExportBans() ([]ban, error) { func (a authFiles) updateTimestamp(name string) { os.Mkdir(Path("auth"), 0700) + path := Path("auth/", name, "/timestamp") + + _, err := os.Stat(path) + if err != nil { + if os.IsNotExist(err) { + f, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE, 0600) + if err != nil { + return + } + + f.Close() + } + + return + } + t := time.Now().Local() - os.Chtimes(Path("auth/", name, "/timestamp"), t, t) + os.Chtimes(path, t, t) } |