MCPcopy Index your code
hub / github.com/celer-pkg/celer / CheckAndRepair

Method CheckAndRepair

configs/rootfs.go:49–71  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

47}
48
49func (r *RootFS) CheckAndRepair() error {
50 // Default folder name is the first folder name of archive name,
51 // but it can be specified by archive name.
52 folderName, _, _ := strings.Cut(r.Path, string(filepath.Separator))
53 if r.Archive != "" {
54 folderName = fileio.Base(r.Archive)
55 }
56
57 // Check and repair resource.
58 archiveName := expr.If(r.Archive != "", r.Archive, filepath.Base(r.Url))
59 toolsDir := filepath.Join(r.ctx.Downloads(), "tools")
60 repair := fileio.NewRepair(r.Url, r.ctx.Downloads(), archiveName, folderName, toolsDir, r.SHA256)
61 if err := repair.CheckAndRepair(r.ctx); err != nil {
62 return err
63 }
64
65 // Print download & extract info.
66 location := filepath.Join(toolsDir, folderName)
67 color.PrintPass("rootfs: %s", fileio.Base(r.Url))
68 color.PrintHint("Location: %s\n", location)
69
70 return nil
71}
72
73func (r RootFS) GetSHA256() string {
74 return r.SHA256

Callers

nothing calls this directly

Calls 7

CheckAndRepairMethod · 0.95
BaseFunction · 0.92
IfFunction · 0.92
NewRepairFunction · 0.92
PrintPassFunction · 0.92
PrintHintFunction · 0.92
DownloadsMethod · 0.65

Tested by

no test coverage detected