@@ -43,12 +43,7 @@ func (n *Notice) TrStr() string {
4343}
4444
4545// CreateNotice creates new system notice.
46- func CreateNotice (tp NoticeType , desc string , args ... interface {}) error {
47- return CreateNoticeCtx (db .DefaultContext , tp , desc , args ... )
48- }
49-
50- // CreateNoticeCtx creates new system notice.
51- func CreateNoticeCtx (ctx context.Context , tp NoticeType , desc string , args ... interface {}) error {
46+ func CreateNotice (ctx context.Context , tp NoticeType , desc string , args ... interface {}) error {
5247 if len (args ) > 0 {
5348 desc = fmt .Sprintf (desc , args ... )
5449 }
@@ -61,38 +56,28 @@ func CreateNoticeCtx(ctx context.Context, tp NoticeType, desc string, args ...in
6156
6257// CreateRepositoryNotice creates new system notice with type NoticeRepository.
6358func CreateRepositoryNotice (desc string , args ... interface {}) error {
64- return CreateNoticeCtx (db .DefaultContext , NoticeRepository , desc , args ... )
59+ return CreateNotice (db .DefaultContext , NoticeRepository , desc , args ... )
6560}
6661
6762// RemoveAllWithNotice removes all directories in given path and
6863// creates a system notice when error occurs.
69- func RemoveAllWithNotice (title , path string ) {
70- RemoveAllWithNoticeCtx (db .DefaultContext , title , path )
71- }
72-
73- // RemoveStorageWithNotice removes a file from the storage and
74- // creates a system notice when error occurs.
75- func RemoveStorageWithNotice (bucket storage.ObjectStorage , title , path string ) {
76- removeStorageWithNotice (db .DefaultContext , bucket , title , path )
77- }
78-
79- func removeStorageWithNotice (ctx context.Context , bucket storage.ObjectStorage , title , path string ) {
80- if err := bucket .Delete (path ); err != nil {
64+ func RemoveAllWithNotice (ctx context.Context , title , path string ) {
65+ if err := util .RemoveAll (path ); err != nil {
8166 desc := fmt .Sprintf ("%s [%s]: %v" , title , path , err )
8267 log .Warn (title + " [%s]: %v" , path , err )
83- if err = CreateNoticeCtx (ctx , NoticeRepository , desc ); err != nil {
68+ if err = CreateNotice (ctx , NoticeRepository , desc ); err != nil {
8469 log .Error ("CreateRepositoryNotice: %v" , err )
8570 }
8671 }
8772}
8873
89- // RemoveAllWithNoticeCtx removes all directories in given path and
74+ // RemoveStorageWithNotice removes a file from the storage and
9075// creates a system notice when error occurs.
91- func RemoveAllWithNoticeCtx (ctx context.Context , title , path string ) {
92- if err := util . RemoveAll (path ); err != nil {
76+ func RemoveStorageWithNotice (ctx context.Context , bucket storage. ObjectStorage , title , path string ) {
77+ if err := bucket . Delete (path ); err != nil {
9378 desc := fmt .Sprintf ("%s [%s]: %v" , title , path , err )
9479 log .Warn (title + " [%s]: %v" , path , err )
95- if err = CreateNoticeCtx (ctx , NoticeRepository , desc ); err != nil {
80+ if err = CreateNotice (ctx , NoticeRepository , desc ); err != nil {
9681 log .Error ("CreateRepositoryNotice: %v" , err )
9782 }
9883 }
0 commit comments