Fix file auth timestamp updater

master
HimbeerserverDE 2021-09-13 17:31:04 +02:00
parent 274a122465
commit 12b0d68687
No known key found for this signature in database
GPG Key ID: 1A651504791E6A8B
1 changed files with 17 additions and 1 deletions

View File

@ -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)
}