diff options
author | KN4CK3R <admin@oldschoolhack.me> | 2021-11-18 18:42:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-19 01:42:27 +0800 |
commit | f34151bdb22c8160b0a6eafef20725ebae1768da (patch) | |
tree | 2abcc5845e4a9cf3769deb27ba5a3ecccd2ad8c9 /models/admin/notice.go | |
parent | 55be5fe3399d18b7d2477519707aecf5f99f1de5 (diff) | |
download | gitea-f34151bdb22c8160b0a6eafef20725ebae1768da.tar.gz gitea-f34151bdb22c8160b0a6eafef20725ebae1768da.zip |
Move user/org deletion to services (#17673)
Diffstat (limited to 'models/admin/notice.go')
-rw-r--r-- | models/admin/notice.go | 33 |
1 files changed, 9 insertions, 24 deletions
diff --git a/models/admin/notice.go b/models/admin/notice.go index c41e49ed8c..2d71b426dd 100644 --- a/models/admin/notice.go +++ b/models/admin/notice.go @@ -43,12 +43,7 @@ func (n *Notice) TrStr() string { } // CreateNotice creates new system notice. -func CreateNotice(tp NoticeType, desc string, args ...interface{}) error { - return CreateNoticeCtx(db.DefaultContext, tp, desc, args...) -} - -// CreateNoticeCtx creates new system notice. -func CreateNoticeCtx(ctx context.Context, tp NoticeType, desc string, args ...interface{}) error { +func CreateNotice(ctx context.Context, tp NoticeType, desc string, args ...interface{}) error { if len(args) > 0 { desc = fmt.Sprintf(desc, args...) } @@ -61,38 +56,28 @@ func CreateNoticeCtx(ctx context.Context, tp NoticeType, desc string, args ...in // CreateRepositoryNotice creates new system notice with type NoticeRepository. func CreateRepositoryNotice(desc string, args ...interface{}) error { - return CreateNoticeCtx(db.DefaultContext, NoticeRepository, desc, args...) + return CreateNotice(db.DefaultContext, NoticeRepository, desc, args...) } // RemoveAllWithNotice removes all directories in given path and // creates a system notice when error occurs. -func RemoveAllWithNotice(title, path string) { - RemoveAllWithNoticeCtx(db.DefaultContext, 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) { - removeStorageWithNotice(db.DefaultContext, bucket, title, path) -} - -func removeStorageWithNotice(ctx context.Context, bucket storage.ObjectStorage, title, path string) { - if err := bucket.Delete(path); err != nil { +func RemoveAllWithNotice(ctx context.Context, title, path string) { + if err := util.RemoveAll(path); err != nil { desc := fmt.Sprintf("%s [%s]: %v", title, path, err) log.Warn(title+" [%s]: %v", path, err) - if err = CreateNoticeCtx(ctx, NoticeRepository, desc); err != nil { + if err = CreateNotice(ctx, NoticeRepository, desc); err != nil { log.Error("CreateRepositoryNotice: %v", err) } } } -// RemoveAllWithNoticeCtx removes all directories in given path and +// RemoveStorageWithNotice removes a file from the storage and // creates a system notice when error occurs. -func RemoveAllWithNoticeCtx(ctx context.Context, title, path string) { - if err := util.RemoveAll(path); err != nil { +func RemoveStorageWithNotice(ctx context.Context, 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 = CreateNoticeCtx(ctx, NoticeRepository, desc); err != nil { + if err = CreateNotice(ctx, NoticeRepository, desc); err != nil { log.Error("CreateRepositoryNotice: %v", err) } } |