mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-15 13:18:51 +01:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
18de05348d
2 changed files with 14 additions and 7 deletions
|
|
@ -69,6 +69,10 @@ func HandleAssetsRemoveEvent(assetAbsPath string) {
|
|||
return
|
||||
}
|
||||
|
||||
if ".DS_Store" == filepath.Base(assetAbsPath) {
|
||||
return
|
||||
}
|
||||
|
||||
removeIndexAssetContent(assetAbsPath)
|
||||
removeAssetThumbnail(assetAbsPath)
|
||||
}
|
||||
|
|
@ -78,6 +82,10 @@ func HandleAssetsChangeEvent(assetAbsPath string) {
|
|||
return
|
||||
}
|
||||
|
||||
if ".DS_Store" == filepath.Base(assetAbsPath) {
|
||||
return
|
||||
}
|
||||
|
||||
indexAssetContent(assetAbsPath)
|
||||
removeAssetThumbnail(assetAbsPath)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ package model
|
|||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/88250/gulu"
|
||||
|
|
@ -71,21 +72,19 @@ func watchAssets() {
|
|||
return
|
||||
}
|
||||
|
||||
if strings.HasSuffix(event.Name, ".tmp") {
|
||||
continue
|
||||
}
|
||||
|
||||
lastEvent = event
|
||||
timer.Reset(time.Millisecond * 100)
|
||||
|
||||
if lastEvent.Op&fsnotify.Rename == fsnotify.Rename || lastEvent.Op&fsnotify.Write == fsnotify.Write {
|
||||
HandleAssetsChangeEvent(lastEvent.Name)
|
||||
} else if lastEvent.Op&fsnotify.Remove == fsnotify.Remove {
|
||||
HandleAssetsRemoveEvent(lastEvent.Name)
|
||||
}
|
||||
case err, ok := <-assetsWatcher.Errors:
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
logging.LogErrorf("watch assets failed: %s", err)
|
||||
case <-timer.C:
|
||||
//logging.LogInfof("assets changed: %s", lastEvent)
|
||||
logging.LogInfof("assets changed: %s", lastEvent)
|
||||
if lastEvent.Op&fsnotify.Write == fsnotify.Write {
|
||||
IncSync()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue