mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-23 10:00:13 +01:00
🎨 Support manual purge of unreferenced data snapshots in the S3/WebDAV cloud storage https://github.com/siyuan-note/siyuan/issues/10081
This commit is contained in:
parent
bb49855133
commit
ce2c774baf
10 changed files with 96 additions and 12 deletions
|
|
@ -419,3 +419,15 @@ func purgeRepo(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
}
|
||||
|
||||
func purgeCloudRepo(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
||||
if err := model.PurgeCloud(); nil != err {
|
||||
ret.Code = -1
|
||||
ret.Msg = fmt.Sprintf(model.Conf.Language(201), err.Error())
|
||||
ret.Data = map[string]interface{}{"closeTimeout": 5000}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -349,6 +349,7 @@ func ServeAPI(ginServer *gin.Engine) {
|
|||
ginServer.Handle("POST", "/api/repo/initRepoKeyFromPassphrase", model.CheckAuth, model.CheckReadonly, initRepoKeyFromPassphrase)
|
||||
ginServer.Handle("POST", "/api/repo/resetRepo", model.CheckAuth, model.CheckReadonly, resetRepo)
|
||||
ginServer.Handle("POST", "/api/repo/purgeRepo", model.CheckAuth, model.CheckReadonly, purgeRepo)
|
||||
ginServer.Handle("POST", "/api/repo/purgeCloudRepo", model.CheckAuth, model.CheckReadonly, purgeCloudRepo)
|
||||
ginServer.Handle("POST", "/api/repo/importRepoKey", model.CheckAuth, model.CheckReadonly, importRepoKey)
|
||||
ginServer.Handle("POST", "/api/repo/createSnapshot", model.CheckAuth, model.CheckReadonly, createSnapshot)
|
||||
ginServer.Handle("POST", "/api/repo/tagSnapshot", model.CheckAuth, model.CheckReadonly, tagSnapshot)
|
||||
|
|
|
|||
|
|
@ -51,9 +51,9 @@ require (
|
|||
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06
|
||||
github.com/sashabaranov/go-openai v1.18.3
|
||||
github.com/shirou/gopsutil/v3 v3.23.12
|
||||
github.com/siyuan-note/dejavu v0.0.0-20240123025532-2ca98172b05f
|
||||
github.com/siyuan-note/dejavu v0.0.0-20240124050424-be48ff329ebf
|
||||
github.com/siyuan-note/encryption v0.0.0-20231219001248-1e028a4d13b4
|
||||
github.com/siyuan-note/eventbus v0.0.0-20240114153055-cf4c124ddf6d
|
||||
github.com/siyuan-note/eventbus v0.0.0-20240124035703-9092bf8e8f48
|
||||
github.com/siyuan-note/filelock v0.0.0-20240121150730-38e4487651d1
|
||||
github.com/siyuan-note/httpclient v0.0.0-20240105083729-70d0557bc690
|
||||
github.com/siyuan-note/logging v0.0.0-20231208035918-61f884c854f0
|
||||
|
|
|
|||
|
|
@ -352,12 +352,12 @@ github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFR
|
|||
github.com/shurcooL/gofontwoff v0.0.0-20181114050219-180f79e6909d h1:lvCTyBbr36+tqMccdGMwuEU+hjux/zL6xSmf5S9ITaA=
|
||||
github.com/shurcooL/gofontwoff v0.0.0-20181114050219-180f79e6909d/go.mod h1:05UtEgK5zq39gLST6uB0cf3NEHjETfB4Fgr3Gx5R9Vw=
|
||||
github.com/simplereach/timeutils v1.2.0/go.mod h1:VVbQDfN/FHRZa1LSqcwo4kNZ62OOyqLLGQKYB3pB0Q8=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20240123025532-2ca98172b05f h1:BsUy5lKm17gbeeTupvSWQH6wlwrou7qiMDe6TZERkYA=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20240123025532-2ca98172b05f/go.mod h1:f5VvNOtytQblmaM4zYgm+VYcokqUR3z6IcrWMhalk6A=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20240124050424-be48ff329ebf h1:C8QfMrXu+/ETqVcgkSASkjXNwJDYeZQXd+pBymAQqYY=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20240124050424-be48ff329ebf/go.mod h1:yFeL7vYskRZBKwtaSRb4t6Ys3ir66P+X4fe55/Rdv7E=
|
||||
github.com/siyuan-note/encryption v0.0.0-20231219001248-1e028a4d13b4 h1:kJaw5L/evyW6LcB9IQT8PR4ppx8JVqOFP9Ix3rfwSrc=
|
||||
github.com/siyuan-note/encryption v0.0.0-20231219001248-1e028a4d13b4/go.mod h1:UYcCCY+0wh+GmUoDOaO63j1sV5lgy7laLAk1XhEiUis=
|
||||
github.com/siyuan-note/eventbus v0.0.0-20240114153055-cf4c124ddf6d h1:ZFhIq+gy5w+FJNX3D4yIp5Aj1H/dM0rrkEdRtk3Ia44=
|
||||
github.com/siyuan-note/eventbus v0.0.0-20240114153055-cf4c124ddf6d/go.mod h1:1/nGgthl89FPA7GzAcEWKl6zRRnfgyTjzLZj9bW7kuw=
|
||||
github.com/siyuan-note/eventbus v0.0.0-20240124035703-9092bf8e8f48 h1:qEeZUvXFIfONrl7Eaf8fSP/NswHkKM2XMbb9yrMNqbY=
|
||||
github.com/siyuan-note/eventbus v0.0.0-20240124035703-9092bf8e8f48/go.mod h1:1/nGgthl89FPA7GzAcEWKl6zRRnfgyTjzLZj9bW7kuw=
|
||||
github.com/siyuan-note/filelock v0.0.0-20240121150730-38e4487651d1 h1:eNHKiqE5yPnj1PYk0PJhxP+oqWdKi+0ZI28lBQmz5qg=
|
||||
github.com/siyuan-note/filelock v0.0.0-20240121150730-38e4487651d1/go.mod h1:CYJQjSyKYLhEJJC+5I+R4uNcpyW0X2CaUYwMVbkelDk=
|
||||
github.com/siyuan-note/httpclient v0.0.0-20240105083729-70d0557bc690 h1:r7qWSaYQhomCAdQl/dZe4NdAn1zadytb4jcOeopdHw4=
|
||||
|
|
|
|||
|
|
@ -502,7 +502,7 @@ func PurgeCloud() (err error) {
|
|||
deletedIndexes := stat.Indexes
|
||||
deletedObjects := stat.Objects
|
||||
deletedSize := humanize.Bytes(uint64(stat.Size))
|
||||
msg = fmt.Sprintf(Conf.Language(203), deletedIndexes, deletedObjects, deletedSize)
|
||||
msg = fmt.Sprintf(Conf.Language(232), deletedIndexes, deletedObjects, deletedSize)
|
||||
util.PushMsg(msg, 5000)
|
||||
return
|
||||
}
|
||||
|
|
@ -1833,6 +1833,32 @@ func subscribeRepoEvents() {
|
|||
eventbus.Subscribe(eventbus.EvtCloudCorrupted, func() {
|
||||
util.PushErrMsg(Conf.language(220), 30000)
|
||||
})
|
||||
eventbus.Subscribe(eventbus.EvtCloudPurgeListObjects, func(context map[string]interface{}) {
|
||||
util.ContextPushMsg(context, Conf.language(224))
|
||||
})
|
||||
eventbus.Subscribe(eventbus.EvtCloudPurgeListIndexes, func(context map[string]interface{}) {
|
||||
util.ContextPushMsg(context, Conf.language(225))
|
||||
})
|
||||
eventbus.Subscribe(eventbus.EvtCloudPurgeListRefs, func(context map[string]interface{}) {
|
||||
util.ContextPushMsg(context, Conf.language(226))
|
||||
})
|
||||
eventbus.Subscribe(eventbus.EvtCloudPurgeDownloadIndex, func(context map[string]interface{}, id string) {
|
||||
msg := fmt.Sprintf(Conf.language(227), id)
|
||||
util.ContextPushMsg(context, msg)
|
||||
})
|
||||
eventbus.Subscribe(eventbus.EvtCloudPurgeDownloadFiles, func(context map[string]interface{}) {
|
||||
msg := Conf.language(228)
|
||||
util.ContextPushMsg(context, msg)
|
||||
})
|
||||
eventbus.Subscribe(eventbus.EvtCloudPurgeRemoveIndexes, func(context map[string]interface{}) {
|
||||
util.ContextPushMsg(context, Conf.language(229))
|
||||
})
|
||||
eventbus.Subscribe(eventbus.EvtCloudPurgeRemoveIndexesV2, func(context map[string]interface{}) {
|
||||
util.ContextPushMsg(context, Conf.language(230))
|
||||
})
|
||||
eventbus.Subscribe(eventbus.EvtCloudPurgeRemoveObjects, func(context map[string]interface{}) {
|
||||
util.ContextPushMsg(context, Conf.language(231))
|
||||
})
|
||||
}
|
||||
|
||||
func buildCloudConf() (ret *cloud.Conf, err error) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue