MCPcopy
hub / github.com/kopia/kopia / FileExists

Method FileExists

snapshot/restore/local_fs_output.go:190–212  ·  view source on GitHub ↗

FileExists implements restore.Output interface.

(_ context.Context, relativePath string, e fs.File)

Source from the content-addressed store, hash-verified

188
189// FileExists implements restore.Output interface.
190func (o *FilesystemOutput) FileExists(_ context.Context, relativePath string, e fs.File) bool {
191 st, err := os.Lstat(filepath.Join(o.TargetPath, relativePath))
192 if err != nil {
193 return false
194 }
195
196 if (st.Mode() & os.ModeType) != 0 {
197 // not a file
198 return false
199 }
200
201 if st.Size() != e.Size() {
202 // wrong size
203 return false
204 }
205
206 timeDelta := st.ModTime().Sub(e.ModTime())
207 if timeDelta < 0 {
208 timeDelta = -timeDelta
209 }
210
211 return timeDelta < maxTimeDeltaToConsiderFileTheSame
212}
213
214// CreateSymlink implements restore.Output interface.
215func (o *FilesystemOutput) CreateSymlink(ctx context.Context, relativePath string, e fs.Symlink) error {

Callers

nothing calls this directly

Calls 4

SubMethod · 0.80
ModeMethod · 0.45
SizeMethod · 0.45
ModTimeMethod · 0.45

Tested by

no test coverage detected