From 381fbd0596f0c69c8f51ca377f4d852a94856e46 Mon Sep 17 00:00:00 2001 From: simlecode <69969590+simlecode@users.noreply.github.com> Date: Tue, 10 Jun 2025 10:51:14 +0800 Subject: [PATCH] fix: restore not check file suffix --- .gitignore | 2 ++ restore.go | 33 +++++++++++++-------------------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index fe73ad8..0575dc4 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,5 @@ .vscode cars2 config.toml +datas +datas2 diff --git a/restore.go b/restore.go index 4411d74..09b75f6 100644 --- a/restore.go +++ b/restore.go @@ -5,7 +5,6 @@ import ( "fmt" "io" "os" - pa "path" "path/filepath" "strings" "sync" @@ -108,10 +107,10 @@ func CarTo(carPath, outputDir string, parallel int) { if fi.IsDir() { return nil } - if strings.ToLower(pa.Ext(fi.Name())) != ".car" { - log.Warn(path, ", it's not a CAR file, skip it") - return nil - } + // if strings.ToLower(pa.Ext(fi.Name())) != ".car" { + // log.Warn(path, ", it's not a CAR file, skip it") + // return nil + // } workerCh <- func() { bs2 := bstore.NewBlockstore(dss.MutexWrap(datastore.NewMapDatastore())) rdag := merkledag.NewDAGService(blockservice.New(bs2, offline.Exchange(bs2))) @@ -147,22 +146,16 @@ func CarTo(carPath, outputDir string, parallel int) { limitCh := make(chan struct{}, parallel) wg := sync.WaitGroup{} func() { - for { - select { - case taskFunc, ok := <-workerCh: - if !ok { - return - } - limitCh <- struct{}{} - wg.Add(1) - go func() { - defer func() { - <-limitCh - wg.Done() - }() - taskFunc() + for taskFunc := range workerCh { + limitCh <- struct{}{} + wg.Add(1) + go func(taskFunc func()) { + defer func() { + <-limitCh + wg.Done() }() - } + taskFunc() + }(taskFunc) } }() wg.Wait()