A Transparent and Verifiable Way to Sync the AT Protocol's PLC Directory

update clone progress, rebuild check

+21 -9
+21 -9
bundle/manager.go
··· 66 66 67 67 // Check for bundle files in directory 68 68 bundleFiles, _ := filepath.Glob(filepath.Join(config.BundleDir, "*.jsonl.zst")) 69 - bundleFiles = filterBundleFiles(bundleFiles) // ← ADD THIS 69 + bundleFiles = filterBundleFiles(bundleFiles) 70 70 hasBundleFiles := len(bundleFiles) > 0 71 71 72 + // Check if clone/download is in progress (look for .tmp files) 73 + tmpFiles, _ := filepath.Glob(filepath.Join(config.BundleDir, "*.tmp")) 74 + cloneInProgress := len(tmpFiles) > 0 75 + 72 76 needsRebuild := false 73 77 74 78 if err != nil { 75 79 // Index doesn't exist or is invalid 76 80 if hasBundleFiles { 77 - // We have bundles but no index - need to rebuild 78 - config.Logger.Printf("No valid index found, but detected %d bundle files", len(bundleFiles)) 79 - needsRebuild = true 81 + if cloneInProgress { 82 + config.Logger.Printf("Clone/download in progress, skipping auto-rebuild") 83 + } else { 84 + // We have bundles but no index - need to rebuild 85 + config.Logger.Printf("No valid index found, but detected %d bundle files", len(bundleFiles)) 86 + needsRebuild = true 87 + } 80 88 } else { 81 89 // No index and no bundles - create fresh index 82 90 config.Logger.Printf("Creating new index at %s", indexPath) ··· 91 99 92 100 // Check if there are bundle files not in the index 93 101 if hasBundleFiles && len(bundleFiles) > index.Count() { 94 - config.Logger.Printf("Detected %d bundle files but index only has %d entries - rebuilding", 95 - len(bundleFiles), index.Count()) 96 - needsRebuild = true 102 + if cloneInProgress { 103 + config.Logger.Printf("Clone/download in progress (%d .tmp files), skipping auto-rebuild", len(tmpFiles)) 104 + } else { 105 + config.Logger.Printf("Detected %d bundle files but index only has %d entries - rebuilding", 106 + len(bundleFiles), index.Count()) 107 + needsRebuild = true 108 + } 97 109 } 98 110 } 99 111 ··· 168 180 bundles := index.GetBundles() 169 181 missingHashes := 0 170 182 for i, meta := range bundles { 171 - if meta.ContentHash == "" { // ← Changed from meta.Hash 183 + if meta.ContentHash == "" { 172 184 missingHashes++ 173 185 } 174 - if i > 0 && meta.Hash == "" { // ← This is now the chain hash 186 + if i > 0 && meta.Hash == "" { 175 187 missingHashes++ 176 188 } 177 189 }