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

Method WriteFile

snapshot/restore/shallow_fs_output.go:51–72  ·  view source on GitHub ↗

WriteFile implements restore.Output interface.

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

Source from the content-addressed store, hash-verified

49
50// WriteFile implements restore.Output interface.
51func (o *ShallowFilesystemOutput) WriteFile(ctx context.Context, relativePath string, f fs.File, _ FileWriteProgress) error {
52 log(ctx).Debugf("(Shallow) WriteFile %v (%v bytes) %v, %v", filepath.Join(o.TargetPath, relativePath), f.Size(), f.Mode(), f.ModTime())
53
54 mde, ok := f.(snapshot.HasDirEntry)
55 if !ok {
56 return errors.Errorf("fs object '%s' is not HasDirEntry?", f.Name())
57 }
58
59 de := mde.DirEntry()
60
61 // Write small files directly instead of writing placeholders.
62 if de.FileSize < int64(o.MinSizeForPlaceholder) {
63 return o.FilesystemOutput.WriteFile(ctx, relativePath, f, nil)
64 }
65
66 placeholderpath, err := o.writeShallowEntry(ctx, relativePath, de)
67 if err != nil {
68 return errors.Wrap(err, "shallow WriteFile")
69 }
70
71 return o.setAttributes(placeholderpath, f, readonlyfilemode)
72}
73
74const readonlyfilemode = 0o222
75

Callers

nothing calls this directly

Calls 9

writeShallowEntryMethod · 0.95
ErrorfMethod · 0.80
setAttributesMethod · 0.80
NameMethod · 0.65
DirEntryMethod · 0.65
WriteFileMethod · 0.65
SizeMethod · 0.45
ModeMethod · 0.45
ModTimeMethod · 0.45

Tested by

no test coverage detected