tangled
alpha
login
or
join now
angrydutchman.peedee.es
/
plcbundle
forked from
atscan.net/plcbundle
0
fork
atom
A Transparent and Verifiable Way to Sync the AT Protocol's PLC Directory
0
fork
atom
overview
issues
pulls
pipelines
update clone progress
tree.fail
4 months ago
24c8a210
a64c3512
+24
-11
1 changed file
expand all
collapse all
unified
split
cmd
plcbundle
main.go
+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
289
+
// Set up progress bar with interrupt tracking
290
290
+
var progress *ProgressBar
291
291
+
var progressMu sync.Mutex
292
292
+
progressActive := true // Track if progress should be updated
293
293
+
289
294
go func() {
290
295
<-sigChan
291
291
-
fmt.Printf("\n\n⚠️ Interrupt received! Finishing current downloads and saving progress...\n")
296
296
+
// Stop progress updates immediately
297
297
+
progressMu.Lock()
298
298
+
progressActive = false
299
299
+
if progress != nil {
300
300
+
fmt.Println() // Move to new line after progress bar
301
301
+
}
302
302
+
progressMu.Unlock()
303
303
+
304
304
+
fmt.Printf("\n⚠️ Interrupt received! Finishing current downloads and saving progress...\n")
292
305
cancel()
293
306
}()
294
307
295
295
-
// Set up progress bar
296
296
-
var progress *ProgressBar
297
297
-
var progressMu sync.Mutex
298
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
319
+
// Stop updating progress if interrupted
320
320
+
if !progressActive {
321
321
+
return
322
322
+
}
323
323
+
310
324
if progress == nil {
311
325
progress = NewProgressBarWithBytes(total, bytesTotal)
312
326
progress.showBytes = true
···
315
329
},
316
330
})
317
331
318
318
-
if progress != nil {
319
319
-
progress.Finish()
320
320
-
}
321
321
-
322
322
-
fmt.Printf("\n")
332
332
+
// Ensure progress is stopped
333
333
+
progressMu.Lock()
334
334
+
progressActive = false
335
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
333
-
fmt.Printf("✓ Clone complete in %s\n", result.Duration.Round(time.Millisecond))
346
346
+
fmt.Printf("\n✓ Clone complete in %s\n", result.Duration.Round(time.Millisecond))
334
347
}
335
348
336
349
fmt.Printf("\nResults:\n")