mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 00:20:47 +02:00
🎨 Improve import S3/WebDAV conf https://github.com/siyuan-note/siyuan/issues/13718
This commit is contained in:
parent
2b0f2e702e
commit
4688ceabb8
1 changed files with 35 additions and 6 deletions
|
@ -22,6 +22,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/siyuan-note/logging"
|
"github.com/siyuan-note/logging"
|
||||||
|
@ -87,10 +88,24 @@ func importSyncProviderWebDAV(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpDir := filepath.Join(importDir, "webdav")
|
tmpDir := filepath.Join(importDir, "webdav")
|
||||||
if err = gulu.Zip.Unzip(tmp, tmpDir); err != nil {
|
os.RemoveAll(tmpDir)
|
||||||
logging.LogErrorf("import WebDAV provider failed: %s", err)
|
if strings.HasSuffix(strings.ToLower(tmp), ".zip") {
|
||||||
|
if err = gulu.Zip.Unzip(tmp, tmpDir); err != nil {
|
||||||
|
logging.LogErrorf("import WebDAV provider failed: %s", err)
|
||||||
|
ret.Code = -1
|
||||||
|
ret.Msg = err.Error()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else if strings.HasSuffix(strings.ToLower(tmp), ".json") {
|
||||||
|
if err = gulu.File.CopyFile(tmp, filepath.Join(tmpDir, f.Filename)); err != nil {
|
||||||
|
logging.LogErrorf("import WebDAV provider failed: %s", err)
|
||||||
|
ret.Code = -1
|
||||||
|
ret.Msg = err.Error()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logging.LogErrorf("invalid WebDAV provider package")
|
||||||
ret.Code = -1
|
ret.Code = -1
|
||||||
ret.Msg = err.Error()
|
ret.Msg = "invalid WebDAV provider package"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,10 +274,24 @@ func importSyncProviderS3(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpDir := filepath.Join(importDir, "s3")
|
tmpDir := filepath.Join(importDir, "s3")
|
||||||
if err = gulu.Zip.Unzip(tmp, tmpDir); err != nil {
|
os.RemoveAll(tmpDir)
|
||||||
logging.LogErrorf("import S3 provider failed: %s", err)
|
if strings.HasSuffix(strings.ToLower(tmp), ".zip") {
|
||||||
|
if err = gulu.Zip.Unzip(tmp, tmpDir); err != nil {
|
||||||
|
logging.LogErrorf("import S3 provider failed: %s", err)
|
||||||
|
ret.Code = -1
|
||||||
|
ret.Msg = err.Error()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else if strings.HasSuffix(strings.ToLower(tmp), ".json") {
|
||||||
|
if err = gulu.File.CopyFile(tmp, filepath.Join(tmpDir, f.Filename)); err != nil {
|
||||||
|
logging.LogErrorf("import S3 provider failed: %s", err)
|
||||||
|
ret.Code = -1
|
||||||
|
ret.Msg = err.Error()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logging.LogErrorf("invalid S3 provider package")
|
||||||
ret.Code = -1
|
ret.Code = -1
|
||||||
ret.Msg = err.Error()
|
ret.Msg = "invalid S3 provider package"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue