@@ -43,12 +43,7 @@ func (n *Notice) TrStr() string {
43
43
}
44
44
45
45
// 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 {
52
47
if len (args ) > 0 {
53
48
desc = fmt .Sprintf (desc , args ... )
54
49
}
@@ -61,38 +56,28 @@ func CreateNoticeCtx(ctx context.Context, tp NoticeType, desc string, args ...in
61
56
62
57
// CreateRepositoryNotice creates new system notice with type NoticeRepository.
63
58
func CreateRepositoryNotice (desc string , args ... interface {}) error {
64
- return CreateNoticeCtx (db .DefaultContext , NoticeRepository , desc , args ... )
59
+ return CreateNotice (db .DefaultContext , NoticeRepository , desc , args ... )
65
60
}
66
61
67
62
// RemoveAllWithNotice removes all directories in given path and
68
63
// 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 {
81
66
desc := fmt .Sprintf ("%s [%s]: %v" , title , path , err )
82
67
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 {
84
69
log .Error ("CreateRepositoryNotice: %v" , err )
85
70
}
86
71
}
87
72
}
88
73
89
- // RemoveAllWithNoticeCtx removes all directories in given path and
74
+ // RemoveStorageWithNotice removes a file from the storage and
90
75
// 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 {
93
78
desc := fmt .Sprintf ("%s [%s]: %v" , title , path , err )
94
79
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 {
96
81
log .Error ("CreateRepositoryNotice: %v" , err )
97
82
}
98
83
}
0 commit comments