1
0
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:
Tw93
2025-12-01 19:26:03 +08:00
parent 4bd4ffc7be
commit 36a84e5211
20 changed files with 1441 additions and 1273 deletions

View File

@@ -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)