🎨 Physically delete a workspace on the mobile https://github.com/siyuan-note/siyuan/issues/9134

This commit is contained in:
Daniel 2023-09-08 15:36:11 +08:00
parent 147d083770
commit 5a9a4a1ece
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
4 changed files with 32 additions and 6 deletions

View file

@ -51,6 +51,7 @@ func ServeAPI(ginServer *gin.Engine) {
ginServer.Handle("POST", "/api/system/checkWorkspaceDir", model.CheckAuth, model.CheckReadonly, checkWorkspaceDir)
ginServer.Handle("POST", "/api/system/createWorkspaceDir", model.CheckAuth, model.CheckReadonly, createWorkspaceDir)
ginServer.Handle("POST", "/api/system/removeWorkspaceDir", model.CheckAuth, model.CheckReadonly, removeWorkspaceDir)
ginServer.Handle("POST", "/api/system/removeWorkspaceDirPhysically", model.CheckAuth, model.CheckReadonly, removeWorkspaceDirPhysically)
ginServer.Handle("POST", "/api/system/setAppearanceMode", model.CheckAuth, setAppearanceMode)
ginServer.Handle("POST", "/api/system/getSysFonts", model.CheckAuth, getSysFonts)
ginServer.Handle("POST", "/api/system/exit", model.CheckAuth, exit)

View file

@ -163,6 +163,31 @@ func removeWorkspaceDir(c *gin.Context) {
}
}
func removeWorkspaceDirPhysically(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
arg, ok := util.JsonArg(c, ret)
if !ok {
return
}
path := arg["path"].(string)
if gulu.File.IsDir(path) {
err := os.RemoveAll(path)
if nil != err {
ret.Code = -1
ret.Msg = err.Error()
return
}
}
if util.WorkspaceDir == path {
os.Exit(logging.ExitCodeOk)
}
}
type Workspace struct {
Path string `json:"path"`
Closed bool `json:"closed"`