🔥 移除旧版云端同步和备份功能入口 https://github.com/siyuan-note/siyuan/issues/5405

This commit is contained in:
Liang Ding 2022-07-13 20:23:04 +08:00
parent e538824819
commit 2863e32cff
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
11 changed files with 63 additions and 710 deletions

View file

@ -1,129 +0,0 @@
// SiYuan - Build Your Eternal Digital Garden
// Copyright (c) 2020-present, b3log.org
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package api
import (
"net/http"
"github.com/88250/gulu"
"github.com/dustin/go-humanize"
"github.com/gin-gonic/gin"
"github.com/siyuan-note/siyuan/kernel/model"
"github.com/siyuan-note/siyuan/kernel/util"
)
func removeCloudBackup(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
err := model.RemoveCloudBackup()
if nil != err {
ret.Code = -1
ret.Msg = err.Error()
return
}
}
func downloadCloudBackup(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
err := model.DownloadBackup()
if nil != err {
ret.Code = -1
ret.Msg = err.Error()
return
}
}
func uploadLocalBackup(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
err := model.UploadBackup()
if nil != err {
ret.Code = -1
ret.Msg = err.Error()
return
}
}
func recoverLocalBackup(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
err := model.RecoverLocalBackup()
if nil != err {
ret.Code = -1
ret.Msg = err.Error()
return
}
}
func createLocalBackup(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
err := model.CreateLocalBackup()
if nil != err {
ret.Code = -1
ret.Msg = err.Error()
return
}
}
func getLocalBackup(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
backup, err := model.GetLocalBackup()
if nil != err {
ret.Code = -1
ret.Msg = err.Error()
return
}
ret.Data = map[string]interface{}{
"backup": backup,
}
}
func getCloudSpace(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
sync, backup, size, assetSize, totalSize, err := model.GetCloudSpace()
if nil != err {
ret.Code = 1
ret.Msg = err.Error()
util.PushErrMsg(err.Error(), 3000)
return
}
hTrafficUploadSize := humanize.Bytes(uint64(model.Conf.User.UserTrafficUpload))
hTrafficDownloadSize := humanize.Bytes(uint64(model.Conf.User.UserTrafficDownload))
ret.Data = map[string]interface{}{
"sync": sync,
"backup": backup,
"hAssetSize": assetSize,
"hSize": size,
"hTotalSize": totalSize,
"hTrafficUploadSize": hTrafficUploadSize,
"hTrafficDownloadSize": hTrafficDownloadSize,
}
}

View file

@ -21,11 +21,38 @@ import (
"net/http"
"github.com/88250/gulu"
"github.com/dustin/go-humanize"
"github.com/gin-gonic/gin"
"github.com/siyuan-note/siyuan/kernel/model"
"github.com/siyuan-note/siyuan/kernel/util"
)
func getCloudSpace(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
sync, backup, size, assetSize, totalSize, err := model.GetCloudSpace()
if nil != err {
ret.Code = 1
ret.Msg = err.Error()
util.PushErrMsg(err.Error(), 3000)
return
}
hTrafficUploadSize := humanize.Bytes(uint64(model.Conf.User.UserTrafficUpload))
hTrafficDownloadSize := humanize.Bytes(uint64(model.Conf.User.UserTrafficDownload))
ret.Data = map[string]interface{}{
"sync": sync,
"backup": backup,
"hAssetSize": assetSize,
"hSize": size,
"hTotalSize": totalSize,
"hTrafficUploadSize": hTrafficUploadSize,
"hTrafficDownloadSize": hTrafficDownloadSize,
}
}
func checkoutRepo(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)

View file

@ -158,13 +158,6 @@ func ServeAPI(ginServer *gin.Engine) {
ginServer.Handle("POST", "/api/cloud/getCloudSpace", model.CheckAuth, getCloudSpace)
ginServer.Handle("POST", "/api/backup/getLocalBackup", model.CheckAuth, getLocalBackup)
ginServer.Handle("POST", "/api/backup/createLocalBackup", model.CheckAuth, model.CheckReadonly, createLocalBackup)
ginServer.Handle("POST", "/api/backup/recoverLocalBackup", model.CheckAuth, model.CheckReadonly, recoverLocalBackup)
ginServer.Handle("POST", "/api/backup/uploadLocalBackup", model.CheckAuth, model.CheckReadonly, uploadLocalBackup)
ginServer.Handle("POST", "/api/backup/downloadCloudBackup", model.CheckAuth, model.CheckReadonly, downloadCloudBackup)
ginServer.Handle("POST", "/api/backup/removeCloudBackup", model.CheckAuth, model.CheckReadonly, removeCloudBackup)
ginServer.Handle("POST", "/api/sync/setSyncEnable", model.CheckAuth, setSyncEnable)
ginServer.Handle("POST", "/api/sync/setSyncMode", model.CheckAuth, setSyncMode)
ginServer.Handle("POST", "/api/sync/setCloudSyncDir", model.CheckAuth, setCloudSyncDir)