MCPcopy Index your code
hub / github.com/kopia/kopia / run

Method run

cli/command_snapshot_create.go:93–174  ·  view source on GitHub ↗

nolint:gocyclo

(ctx context.Context, rep repo.RepositoryWriter)

Source from the content-addressed store, hash-verified

91
92//nolint:gocyclo
93func (c *commandSnapshotCreate) run(ctx context.Context, rep repo.RepositoryWriter) error {
94 sources := c.snapshotCreateSources
95
96 if c.snapshotCreateAll && len(sources) > 0 {
97 return errors.New("cannot use --all when a source path argument is specified")
98 }
99
100 if err := maybeAutoUpgradeRepository(ctx, rep); err != nil {
101 return errors.Wrap(err, "error upgrading repository")
102 }
103
104 if c.snapshotCreateAll {
105 local, err := getLocalBackupPaths(ctx, rep)
106 if err != nil {
107 return err
108 }
109
110 sources = append(sources, local...)
111 }
112
113 if len(sources) == 0 {
114 return errors.New("no snapshot sources")
115 }
116
117 if err := validateStartEndTime(c.snapshotCreateStartTime, c.snapshotCreateEndTime); err != nil {
118 return err
119 }
120
121 if len(c.snapshotCreateDescription) > maxSnapshotDescriptionLength {
122 return errors.New("description too long")
123 }
124
125 u := c.setupUploader(rep)
126
127 var finalErrors []string
128
129 tags, err := getTags(c.snapshotCreateTags)
130 if err != nil {
131 return err
132 }
133
134 var st notifydata.MultiSnapshotStatus
135
136 for _, snapshotDir := range sources {
137 if u.IsCanceled() {
138 log(ctx).Info("Upload canceled")
139 break
140 }
141
142 fsEntry, sourceInfo, setManual, err := c.getContentToSnapshot(ctx, snapshotDir, rep)
143 if err != nil {
144 finalErrors = append(finalErrors, fmt.Sprintf("failed to prepare source: %s", err))
145 }
146
147 if err := c.snapshotSingleSource(ctx, fsEntry, setManual, rep, u, sourceInfo, tags, &st); err != nil {
148 finalErrors = append(finalErrors, err.Error())
149 }
150 }

Callers

nothing calls this directly

Calls 15

setupUploaderMethod · 0.95
getContentToSnapshotMethod · 0.95
snapshotSingleSourceMethod · 0.95
reportSeverityMethod · 0.95
SendFunction · 0.92
getLocalBackupPathsFunction · 0.85
validateStartEndTimeFunction · 0.85
getTagsFunction · 0.85
IsCanceledMethod · 0.80
InfoMethod · 0.80
ErrorfMethod · 0.80

Tested by

no test coverage detected