diff options
Diffstat (limited to 'models/admin.go')
-rw-r--r-- | models/admin.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/models/admin.go b/models/admin.go index ebd01419a8..9ed9c44ebb 100644 --- a/models/admin.go +++ b/models/admin.go @@ -1,4 +1,5 @@ // Copyright 2014 The Gogs Authors. All rights reserved. +// Copyright 2020 The Gitea Authors. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. @@ -8,6 +9,7 @@ import ( "fmt" "code.gitea.io/gitea/modules/log" + "code.gitea.io/gitea/modules/storage" "code.gitea.io/gitea/modules/timeutil" "code.gitea.io/gitea/modules/util" @@ -65,6 +67,18 @@ func RemoveAllWithNotice(title, path string) { removeAllWithNotice(x, title, path) } +// RemoveStorageWithNotice removes a file from the storage and +// creates a system notice when error occurs. +func RemoveStorageWithNotice(bucket storage.ObjectStorage, title, path string) { + if err := bucket.Delete(path); err != nil { + desc := fmt.Sprintf("%s [%s]: %v", title, path, err) + log.Warn(title+" [%s]: %v", path, err) + if err = createNotice(x, NoticeRepository, desc); err != nil { + log.Error("CreateRepositoryNotice: %v", err) + } + } +} + func removeAllWithNotice(e Engine, title, path string) { if err := util.RemoveAll(path); err != nil { desc := fmt.Sprintf("%s [%s]: %v", title, path, err) |