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

update clone progress

+24 -11
+24 -11
cmd/plcbundle/main.go
··· 286 286 sigChan := make(chan os.Signal, 1) 287 287 signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM) 288 288 289 + // Set up progress bar with interrupt tracking 290 + var progress *ProgressBar 291 + var progressMu sync.Mutex 292 + progressActive := true // Track if progress should be updated 293 + 289 294 go func() { 290 295 <-sigChan 291 - fmt.Printf("\n\n⚠️ Interrupt received! Finishing current downloads and saving progress...\n") 296 + // Stop progress updates immediately 297 + progressMu.Lock() 298 + progressActive = false 299 + if progress != nil { 300 + fmt.Println() // Move to new line after progress bar 301 + } 302 + progressMu.Unlock() 303 + 304 + fmt.Printf("\n⚠️ Interrupt received! Finishing current downloads and saving progress...\n") 292 305 cancel() 293 306 }() 294 307 295 - // Set up progress bar 296 - var progress *ProgressBar 297 - var progressMu sync.Mutex 298 - 299 308 // Clone with library 300 309 result, err := mgr.CloneFromRemote(ctx, bundle.CloneOptions{ 301 310 RemoteURL: remoteURL, ··· 307 316 progressMu.Lock() 308 317 defer progressMu.Unlock() 309 318 319 + // Stop updating progress if interrupted 320 + if !progressActive { 321 + return 322 + } 323 + 310 324 if progress == nil { 311 325 progress = NewProgressBarWithBytes(total, bytesTotal) 312 326 progress.showBytes = true ··· 315 329 }, 316 330 }) 317 331 318 - if progress != nil { 319 - progress.Finish() 320 - } 321 - 322 - fmt.Printf("\n") 332 + // Ensure progress is stopped 333 + progressMu.Lock() 334 + progressActive = false 335 + progressMu.Unlock() 323 336 324 337 if err != nil { 325 338 fmt.Fprintf(os.Stderr, "Clone failed: %v\n", err) ··· 330 343 if result.Interrupted { 331 344 fmt.Printf("⚠️ Download interrupted by user\n") 332 345 } else { 333 - fmt.Printf("✓ Clone complete in %s\n", result.Duration.Round(time.Millisecond)) 346 + fmt.Printf("\n✓ Clone complete in %s\n", result.Duration.Round(time.Millisecond)) 334 347 } 335 348 336 349 fmt.Printf("\nResults:\n")