🎨 同步忽略文件配置使用 gitignore 规则 https://github.com/siyuan-note/siyuan/issues/5295

This commit is contained in:
Liang Ding 2022-06-27 11:24:20 +08:00
parent 4c81634ab7
commit 070f51a3ab
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
6 changed files with 18 additions and 227 deletions

View file

@ -38,7 +38,6 @@ import (
"github.com/88250/lute/html"
"github.com/88250/lute/parse"
"github.com/88250/protyle"
"github.com/mattn/go-zglob"
"github.com/siyuan-note/filelock"
"github.com/siyuan-note/siyuan/kernel/filesys"
"github.com/siyuan-note/siyuan/kernel/sql"
@ -234,21 +233,22 @@ func ImportSY(zipPath, boxID, toPath string) (err error) {
}
}
assetsDirs, err := zglob.Glob(unzipRootPath + "/**/assets")
if nil != err {
return
}
if 0 < len(assetsDirs) {
for _, assets := range assetsDirs {
if gulu.File.IsDir(assets) {
dataAssets := filepath.Join(util.DataDir, "assets")
if err = gulu.File.Copy(assets, dataAssets); nil != err {
util.LogErrorf("copy assets from [%s] to [%s] failed: %s", assets, dataAssets, err)
return
}
}
os.RemoveAll(assets)
var assetsDirs []string
filepath.Walk(unzipRootPath, func(path string, info fs.FileInfo, err error) error {
if strings.Contains(path, "assets") && info.IsDir() {
assetsDirs = append(assetsDirs, path)
}
return nil
})
for _, assets := range assetsDirs {
if gulu.File.IsDir(assets) {
dataAssets := filepath.Join(util.DataDir, "assets")
if err = gulu.File.Copy(assets, dataAssets); nil != err {
util.LogErrorf("copy assets from [%s] to [%s] failed: %s", assets, dataAssets, err)
return
}
}
os.RemoveAll(assets)
}
writingDataLock.Lock()