From 2efe33a1dae1aec100a09001e266d4e5c5204c90 Mon Sep 17 00:00:00 2001 From: cheetah Date: Fri, 7 Jul 2023 05:22:45 -0500 Subject: [PATCH] skipping n addons option --- main.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/main.go b/main.go index bae0626..9d712d9 100644 --- a/main.go +++ b/main.go @@ -123,7 +123,7 @@ func main() { workerModeP := flag.String("mode", "", "mode (ingress, rebuild)") debugEnabled := flag.Bool("debug", false, "enables debug") folderPathP := flag.String("path", "/mnt/SC9000/TemporaryTestingShit2", "a string") - skipNameP := flag.String("skip", "", "skip until this name") + skipNameP := flag.Int("skip", -1, "skip n addons") workerNameP := flag.String("worker", "def", "worker name") rebuildIDP := flag.String("id", "", "id to rebuild") @@ -285,8 +285,8 @@ func recursive(jobs []string, folderPath string) (WorkerJobPool []string) { return jobs } -func modeIngress(folderPath string, skipName string) { - skipNameEnabled := len(skipName) > 0 +func modeIngress(folderPath string, skipN int) { + // skipNameEnabled := skipN > 0 entries, err := os.ReadDir(folderPath) if err != nil { panic(err) @@ -298,17 +298,13 @@ func modeIngress(folderPath string, skipName string) { if e.IsDir() { WorkerJobPool = recursive(WorkerJobPool, fullPath) } - if !e.IsDir() && skipNameEnabled { - if e.Name() == skipName { - skipNameEnabled = false - } else { - continue - } - } if !e.IsDir() { WorkerJobPool = append(WorkerJobPool, filepath.Join(folderPath, e.Name())) } } + if skipN > 0 { + WorkerJobPool = WorkerJobPool[skipN:] + } wg := sync.WaitGroup{} pw := progress.NewWriter() @@ -560,6 +556,9 @@ func ProcessGMA(pw progress.Writer, filePath string) (err error) { dboGMA2Files = append(dboGMA2Files, dboGMA2File) trackerProcess.Increment(1) } + if len(files) < 1 { + return fmt.Errorf("GMA empty, len=%d", len(files)) + } lastFile := files[len(files)-1] dboGMA.FooterAddonCRC, err = gmaReader.ReadAddonCRC(lastFile.Offset + lastFile.FileSize)