ax_rd
3 hours ago 62a9f6223745c0df42be1f4226f31dfb10c83ea8
internal/index/cache.go
@@ -14,35 +14,3 @@
   }
   return strings.TrimSpace(string(out)), nil
}
// NeedsRebuild 检查是否需要重建索引
func NeedsRebuild(store *Store, vaultPath string) (bool, string, error) {
   currentCommit, err := GetGitCommit(vaultPath)
   if err != nil {
      // 不是 git 仓库,总是需要重建
      return true, "", nil
   }
   storedCommit, err := store.GetMeta("git_commit")
   if err != nil {
      return true, currentCommit, nil
   }
   if storedCommit == "" {
      // 没有记录,需要重建
      return true, currentCommit, nil
   }
   if storedCommit != currentCommit {
      // commit 变了,需要重建
      return true, currentCommit, nil
   }
   // 检查是否有节点
   count, _ := store.NodeCount()
   if count == 0 {
      return true, currentCommit, nil
   }
   return false, currentCommit, nil
}