MCPcopy
hub / github.com/kopia/kopia / listDirectory

Method listDirectory

cli/command_ls.go:58–89  ·  view source on GitHub ↗
(ctx context.Context, d fs.Directory, prefix, indent string)

Source from the content-addressed store, hash-verified

56}
57
58func (c *commandList) listDirectory(ctx context.Context, d fs.Directory, prefix, indent string) error {
59 iter, err := d.Iterate(ctx)
60 if err != nil {
61 return err //nolint:wrapcheck
62 }
63 defer iter.Close()
64
65 e, err := iter.Next(ctx)
66 for e != nil {
67 if err2 := c.printDirectoryEntry(ctx, e, prefix, indent); err2 != nil {
68 return err2
69 }
70
71 e, err = iter.Next(ctx)
72 }
73
74 if err != nil {
75 return err //nolint:wrapcheck
76 }
77
78 if dws, ok := d.(fs.DirectoryWithSummary); ok && c.errorSummary {
79 if ds, _ := dws.Summary(ctx); ds != nil && ds.FatalErrorCount > 0 {
80 errorColor.Fprintf(c.out.stderr(), "\nNOTE: Encountered %v errors while snapshotting this directory:\n\n", ds.FatalErrorCount) //nolint:errcheck
81
82 for _, e := range ds.FailedEntries {
83 errorColor.Fprintf(c.out.stderr(), "- Error in \"%v\": %v\n", e.EntryPath, e.Error) //nolint:errcheck
84 }
85 }
86 }
87
88 return nil
89}
90
91func (c *commandList) printDirectoryEntry(ctx context.Context, e fs.Entry, prefix, indent string) error {
92 hoid, ok := e.(object.HasObjectID)

Callers 2

runMethod · 0.95
printDirectoryEntryMethod · 0.95

Calls 6

printDirectoryEntryMethod · 0.95
stderrMethod · 0.80
IterateMethod · 0.65
CloseMethod · 0.65
NextMethod · 0.65
SummaryMethod · 0.65

Tested by

no test coverage detected