🐛 无法插入资源文件的问题 Fix https://github.com/siyuan-note/siyuan/issues/5971
This commit is contained in:
parent
f7d91a67b9
commit
e536f5d4b6
2 changed files with 12 additions and 1 deletions
3
kernel/cache/asset.go
vendored
3
kernel/cache/asset.go
vendored
|
@ -45,6 +45,9 @@ func LoadAssets() {
|
|||
|
||||
assets := filepath.Join(util.DataDir, "assets")
|
||||
filepath.Walk(assets, func(path string, info fs.FileInfo, err error) error {
|
||||
if nil == info {
|
||||
return err
|
||||
}
|
||||
if info.IsDir() {
|
||||
if strings.HasPrefix(info.Name(), ".") {
|
||||
return filepath.SkipDir
|
||||
|
|
|
@ -45,6 +45,12 @@ func InsertLocalAssets(id string, assetPaths []string) (succMap map[string]inter
|
|||
|
||||
docDirLocalPath := filepath.Join(util.DataDir, bt.BoxID, path.Dir(bt.Path))
|
||||
assets := getAssetsDir(filepath.Join(util.DataDir, bt.BoxID), docDirLocalPath)
|
||||
if !gulu.File.IsExist(assets) {
|
||||
if err = os.MkdirAll(assets, 0755); nil != err {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
for _, p := range assetPaths {
|
||||
fName := filepath.Base(p)
|
||||
fName = util.FilterUploadFileName(fName)
|
||||
|
@ -124,7 +130,9 @@ func Upload(c *gin.Context) {
|
|||
if nil != form.Value["assetsDirPath"] {
|
||||
assetsDirPath = form.Value["assetsDirPath"][0]
|
||||
assetsDirPath = filepath.Join(util.DataDir, assetsDirPath)
|
||||
if err := os.MkdirAll(assetsDirPath, 0755); nil != err {
|
||||
}
|
||||
if !gulu.File.IsExist(assetsDirPath) {
|
||||
if err = os.MkdirAll(assetsDirPath, 0755); nil != err {
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
return
|
||||
|
|
Loading…
Add table
Reference in a new issue