MCPcopy
hub / github.com/perkeep/perkeep / populateAttr

Method populateAttr

pkg/fs/fs.go:282–318  ·  view source on GitHub ↗

populateAttr should only be called once n.ss is known to be set and non-nil

()

Source from the content-addressed store, hash-verified

280// populateAttr should only be called once n.ss is known to be set and
281// non-nil
282func (n *node) populateAttr() error {
283 meta := n.meta
284
285 n.attr.Mode = meta.FileMode()
286
287 if n.fs.IgnoreOwners {
288 n.attr.Uid = uint32(os.Getuid())
289 n.attr.Gid = uint32(os.Getgid())
290 executeBit := n.attr.Mode & 0100
291 n.attr.Mode = (n.attr.Mode ^ n.attr.Mode.Perm()) | 0400 | executeBit
292 } else {
293 n.attr.Uid = uint32(meta.MapUid())
294 n.attr.Gid = uint32(meta.MapGid())
295 }
296
297 // TODO: inode?
298
299 if mt := meta.ModTime(); !mt.IsZero() {
300 n.attr.Mtime = mt
301 } else {
302 n.attr.Mtime = n.pnodeModTime
303 }
304
305 switch meta.Type() {
306 case schema.TypeFile:
307 n.attr.Size = uint64(meta.PartsSize())
308 n.attr.Blocks = 0 // TODO: set?
309 n.attr.Mode |= 0400
310 case schema.TypeDirectory:
311 n.attr.Mode |= 0500
312 case schema.TypeSymlink:
313 n.attr.Mode |= 0400
314 default:
315 Logger.Printf("unknown attr ss.Type %q in populateAttr", meta.Type())
316 }
317 return nil
318}
319
320func (fs *CamliFileSystem) Root() (fusefs.Node, error) {
321 return fs.root, nil

Callers 2

schemaMethod · 0.95
newNodeFromBlobRefMethod · 0.95

Calls 7

PrintfMethod · 0.80
FileModeMethod · 0.45
MapUidMethod · 0.45
MapGidMethod · 0.45
ModTimeMethod · 0.45
TypeMethod · 0.45
PartsSizeMethod · 0.45

Tested by

no test coverage detected