MCPcopy
hub / github.com/kopia/kopia / newDirEntry

Function newDirEntry

snapshot/upload/upload.go:450–474  ·  view source on GitHub ↗

newDirEntry makes DirEntry objects for any type of Entry.

(md fs.Entry, fname string, oid object.ID)

Source from the content-addressed store, hash-verified

448
449// newDirEntry makes DirEntry objects for any type of Entry.
450func newDirEntry(md fs.Entry, fname string, oid object.ID) (*snapshot.DirEntry, error) {
451 var entryType snapshot.EntryType
452
453 switch md := md.(type) {
454 case fs.Directory:
455 entryType = snapshot.EntryTypeDirectory
456 case fs.Symlink:
457 entryType = snapshot.EntryTypeSymlink
458 case fs.File, fs.StreamingFile:
459 entryType = snapshot.EntryTypeFile
460 default:
461 return nil, errors.Errorf("invalid entry type %T", md)
462 }
463
464 return &snapshot.DirEntry{
465 Name: fname,
466 Type: entryType,
467 Permissions: snapshot.Permissions(md.Mode() & fs.ModBits),
468 FileSize: md.Size(),
469 ModTime: fs.UTCTimestampFromTime(md.ModTime()),
470 UserID: md.Owner().UserID,
471 GroupID: md.Owner().GroupID,
472 ObjectID: oid,
473 }, nil
474}
475
476// newCachedDirEntry makes DirEntry objects for entries that are also in
477// previous snapshots. It ensures file sizes are populated correctly for

Callers 5

uploadFileDataMethod · 0.85
uploadSymlinkInternalMethod · 0.85
newDirEntryWithSummaryFunction · 0.85
newCachedDirEntryFunction · 0.85

Calls 7

PermissionsTypeAlias · 0.92
UTCTimestampFromTimeFunction · 0.92
ErrorfMethod · 0.80
OwnerMethod · 0.65
ModeMethod · 0.45
SizeMethod · 0.45
ModTimeMethod · 0.45

Tested by

no test coverage detected