mirror of
https://github.com/tw93/Mole.git
synced 2026-02-11 08:19:18 +00:00
Reconstruct the structure of go
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/gob"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
@@ -291,7 +292,7 @@ func removeOverviewSnapshot(path string) {
|
||||
|
||||
// prefetchOverviewCache scans overview directories in background
|
||||
// to populate cache for faster overview mode access
|
||||
func prefetchOverviewCache() {
|
||||
func prefetchOverviewCache(ctx context.Context) {
|
||||
entries := createOverviewEntries()
|
||||
|
||||
// Check which entries need refresh
|
||||
@@ -309,8 +310,15 @@ func prefetchOverviewCache() {
|
||||
return
|
||||
}
|
||||
|
||||
// Scan and cache in background
|
||||
// Scan and cache in background with context cancellation support
|
||||
for _, path := range needScan {
|
||||
// Check if context is cancelled
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
size, err := measureOverviewSize(path)
|
||||
if err == nil && size > 0 {
|
||||
_ = storeOverviewSize(path, size)
|
||||
|
||||
Reference in New Issue
Block a user