mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-10 17:24:21 +01:00
♻️ Refactor Go to err != nil, err == nil (#12385)
This commit is contained in:
parent
473a159ef2
commit
b100721fee
147 changed files with 1661 additions and 1659 deletions
|
|
@ -45,7 +45,7 @@ func exportAttributeView(c *gin.Context) {
|
|||
avID := arg["id"].(string)
|
||||
blockID := arg["blockID"].(string)
|
||||
zipPath, err := model.ExportAv2CSV(avID, blockID)
|
||||
if nil != err {
|
||||
if err != nil {
|
||||
ret.Code = 1
|
||||
ret.Msg = err.Error()
|
||||
ret.Data = map[string]interface{}{"closeTimeout": 7000}
|
||||
|
|
@ -221,7 +221,7 @@ func export2Liandi(c *gin.Context) {
|
|||
|
||||
id := arg["id"].(string)
|
||||
err := model.Export2Liandi(id)
|
||||
if nil != err {
|
||||
if err != nil {
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
return
|
||||
|
|
@ -239,7 +239,7 @@ func exportDataInFolder(c *gin.Context) {
|
|||
|
||||
exportFolder := arg["folder"].(string)
|
||||
name, err := model.ExportDataInFolder(exportFolder)
|
||||
if nil != err {
|
||||
if err != nil {
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
ret.Data = map[string]interface{}{"closeTimeout": 7000}
|
||||
|
|
@ -255,7 +255,7 @@ func exportData(c *gin.Context) {
|
|||
defer c.JSON(http.StatusOK, ret)
|
||||
|
||||
zipPath, err := model.ExportData()
|
||||
if nil != err {
|
||||
if err != nil {
|
||||
ret.Code = 1
|
||||
ret.Msg = err.Error()
|
||||
ret.Data = map[string]interface{}{"closeTimeout": 7000}
|
||||
|
|
@ -296,7 +296,7 @@ func exportResources(c *gin.Context) {
|
|||
}
|
||||
|
||||
zipFilePath, err := model.ExportResources(resourcePaths, name)
|
||||
if nil != err {
|
||||
if err != nil {
|
||||
ret.Code = 1
|
||||
ret.Msg = err.Error()
|
||||
ret.Data = map[string]interface{}{"closeTimeout": 7000}
|
||||
|
|
@ -414,7 +414,7 @@ func exportDocx(c *gin.Context) {
|
|||
}
|
||||
|
||||
fullPath, err := model.ExportDocx(id, savePath, removeAssets, merge)
|
||||
if nil != err {
|
||||
if err != nil {
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
ret.Data = map[string]interface{}{"closeTimeout": 7000}
|
||||
|
|
@ -455,14 +455,14 @@ func exportTempContent(c *gin.Context) {
|
|||
|
||||
content := arg["content"].(string)
|
||||
tmpExport := filepath.Join(util.TempDir, "export", "temp")
|
||||
if err := os.MkdirAll(tmpExport, 0755); nil != err {
|
||||
if err := os.MkdirAll(tmpExport, 0755); err != nil {
|
||||
ret.Code = 1
|
||||
ret.Msg = err.Error()
|
||||
ret.Data = map[string]interface{}{"closeTimeout": 7000}
|
||||
return
|
||||
}
|
||||
p := filepath.Join(tmpExport, gulu.Rand.String(7))
|
||||
if err := os.WriteFile(p, []byte(content), 0644); nil != err {
|
||||
if err := os.WriteFile(p, []byte(content), 0644); err != nil {
|
||||
ret.Code = 1
|
||||
ret.Msg = err.Error()
|
||||
ret.Data = map[string]interface{}{"closeTimeout": 7000}
|
||||
|
|
@ -563,7 +563,7 @@ func processPDF(c *gin.Context) {
|
|||
removeAssets := arg["removeAssets"].(bool)
|
||||
watermark := arg["watermark"].(bool)
|
||||
err := model.ProcessPDF(id, path, merge, removeAssets, watermark)
|
||||
if nil != err {
|
||||
if err != nil {
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
return
|
||||
|
|
@ -592,7 +592,7 @@ func exportAsFile(c *gin.Context) {
|
|||
defer c.JSON(http.StatusOK, ret)
|
||||
|
||||
form, err := c.MultipartForm()
|
||||
if nil != err {
|
||||
if err != nil {
|
||||
logging.LogErrorf("export as file failed: %s", err)
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
|
|
@ -601,7 +601,7 @@ func exportAsFile(c *gin.Context) {
|
|||
|
||||
file := form.File["file"][0]
|
||||
reader, err := file.Open()
|
||||
if nil != err {
|
||||
if err != nil {
|
||||
logging.LogErrorf("export as file failed: %s", err)
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
|
|
@ -610,7 +610,7 @@ func exportAsFile(c *gin.Context) {
|
|||
defer reader.Close()
|
||||
|
||||
data, err := io.ReadAll(reader)
|
||||
if nil != err {
|
||||
if err != nil {
|
||||
logging.LogErrorf("export as file failed: %s", err)
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
|
|
@ -620,7 +620,7 @@ func exportAsFile(c *gin.Context) {
|
|||
name := "file-" + file.Filename
|
||||
name = util.FilterFileName(name)
|
||||
tmpDir := filepath.Join(util.TempDir, "export")
|
||||
if err = os.MkdirAll(tmpDir, 0755); nil != err {
|
||||
if err = os.MkdirAll(tmpDir, 0755); err != nil {
|
||||
logging.LogErrorf("export as file failed: %s", err)
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
|
|
@ -629,7 +629,7 @@ func exportAsFile(c *gin.Context) {
|
|||
|
||||
tmp := filepath.Join(tmpDir, name)
|
||||
err = os.WriteFile(tmp, data, 0644)
|
||||
if nil != err {
|
||||
if err != nil {
|
||||
logging.LogErrorf("export as file failed: %s", err)
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue