|
@@ -74,9 +74,10 @@ func watchAssets() {
|
|
|
lastEvent = event
|
|
|
timer.Reset(time.Millisecond * 100)
|
|
|
|
|
|
- if lastEvent.Op&fsnotify.Rename == fsnotify.Rename {
|
|
|
- // 索引资源文件内容
|
|
|
+ if lastEvent.Op&fsnotify.Rename == fsnotify.Rename || lastEvent.Op&fsnotify.Write == fsnotify.Write {
|
|
|
IndexAssetContent(lastEvent.Name)
|
|
|
+ } else if lastEvent.Op&fsnotify.Remove == fsnotify.Remove {
|
|
|
+ RemoveIndexAssetContent(lastEvent.Name)
|
|
|
}
|
|
|
case err, ok := <-assetsWatcher.Errors:
|
|
|
if !ok {
|
|
@@ -86,15 +87,17 @@ func watchAssets() {
|
|
|
case <-timer.C:
|
|
|
//logging.LogInfof("assets changed: %s", lastEvent)
|
|
|
if lastEvent.Op&fsnotify.Write == fsnotify.Write {
|
|
|
- // 外部修改已有资源文件后纳入云端同步 https://github.com/siyuan-note/siyuan/issues/4694
|
|
|
IncSync()
|
|
|
}
|
|
|
|
|
|
// 重新缓存资源文件,以便使用 /资源 搜索
|
|
|
go cache.LoadAssets()
|
|
|
|
|
|
- // 索引资源文件内容
|
|
|
- IndexAssetContent(lastEvent.Name)
|
|
|
+ if lastEvent.Op&fsnotify.Remove == fsnotify.Remove {
|
|
|
+ RemoveIndexAssetContent(lastEvent.Name)
|
|
|
+ } else {
|
|
|
+ IndexAssetContent(lastEvent.Name)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}()
|