MCPcopy
hub / github.com/moonD4rk/HackBrowserData / extractAndWrite

Function extractAndWrite

cmd/hack-browser-data/extract.go:14–39  ·  view source on GitHub ↗
(browsers []browser.Browser, categories []types.Category, outputDir, outputFormat string, compress bool)

Source from the content-addressed store, hash-verified

12)
13
14func extractAndWrite(browsers []browser.Browser, categories []types.Category, outputDir, outputFormat string, compress bool) error {
15 w, err := output.NewWriter(outputDir, outputFormat)
16 if err != nil {
17 return err
18 }
19 for _, b := range browsers {
20 log.Infof("Extracting %s...", b.BrowserName())
21 results, extractErr := b.Extract(categories)
22 if extractErr != nil {
23 log.Errorf("extract %s: %v", b.BrowserName(), extractErr)
24 }
25 for _, r := range results {
26 w.Add(b.BrowserName(), r.Name, r.Data)
27 }
28 }
29 if err := w.Write(); err != nil {
30 return err
31 }
32 if compress {
33 if err := fileutil.CompressDir(outputDir); err != nil {
34 return fmt.Errorf("compress: %w", err)
35 }
36 log.Infof("Compressed: %s/%s.zip", outputDir, filepath.Base(outputDir))
37 }
38 return nil
39}

Callers 2

restoreCmdFunction · 0.85
dumpCmdFunction · 0.85

Calls 9

AddMethod · 0.95
WriteMethod · 0.95
NewWriterFunction · 0.92
InfofFunction · 0.92
ErrorfFunction · 0.92
CompressDirFunction · 0.92
ErrorfMethod · 0.80
BrowserNameMethod · 0.65
ExtractMethod · 0.65

Tested by

no test coverage detected