Browse Source

:art: 资源文件夹不存在时自动创建

Liang Ding 2 years ago
parent
commit
7959a6a994
1 changed files with 6 additions and 0 deletions
  1. 6 0
      kernel/model/assets_watcher.go

+ 6 - 0
kernel/model/assets_watcher.go

@@ -19,9 +19,11 @@
 package model
 
 import (
+	"os"
 	"path/filepath"
 	"time"
 
+	"github.com/88250/gulu"
 	"github.com/fsnotify/fsnotify"
 	"github.com/siyuan-note/logging"
 	"github.com/siyuan-note/siyuan/kernel/cache"
@@ -89,6 +91,10 @@ func watchAssets() {
 		}
 	}()
 
+	if !gulu.File.IsDir(assetsDir) {
+		os.MkdirAll(assetsDir, 0755)
+	}
+
 	if err = assetsWatcher.Add(assetsDir); err != nil {
 		logging.LogErrorf("add assets watcher for folder [%s] failed: %s", assetsDir, err)
 	}