MCPcopy
hub / github.com/kopia/kopia / WriteFile

Method WriteFile

snapshot/restore/local_fs_output.go:174–187  ·  view source on GitHub ↗

WriteFile implements restore.Output interface.

(ctx context.Context, relativePath string, f fs.File, progressCb FileWriteProgress)

Source from the content-addressed store, hash-verified

172
173// WriteFile implements restore.Output interface.
174func (o *FilesystemOutput) WriteFile(ctx context.Context, relativePath string, f fs.File, progressCb FileWriteProgress) error {
175 log(ctx).Debugf("WriteFile %v (%v bytes) %v, %v", filepath.Join(o.TargetPath, relativePath), f.Size(), f.Mode(), f.ModTime())
176 path := filepath.Join(o.TargetPath, filepath.FromSlash(relativePath))
177
178 if err := o.copyFileContent(ctx, path, f, progressCb); err != nil {
179 return errors.Wrap(err, "error creating file")
180 }
181
182 if err := o.setAttributes(path, f, os.FileMode(0)); err != nil {
183 return errors.Wrap(err, "error setting attributes")
184 }
185
186 return SafeRemoveAll(path)
187}
188
189// FileExists implements restore.Output interface.
190func (o *FilesystemOutput) FileExists(_ context.Context, relativePath string, e fs.File) bool {

Callers

nothing calls this directly

Calls 6

copyFileContentMethod · 0.95
setAttributesMethod · 0.95
SafeRemoveAllFunction · 0.85
SizeMethod · 0.45
ModeMethod · 0.45
ModTimeMethod · 0.45

Tested by

no test coverage detected