Exemple #1
0
// Return an appropriate score map key for the node, or nil if the score map
// should not be used.
func makeScoreMapKey(
	node *fsNode,
	clock timeutil.Clock) (key *state.ScoreMapKey) {
	// Skip non-files.
	if node.Info.Type != fs.TypeFile {
		return
	}

	// If the mtime of the file is not far enough in the past, we don't want to
	// do any fancy caching, for fear of race conditions.
	const minElapsed = 5 * time.Minute
	if clock.Now().Sub(node.Info.MTime) < minElapsed {
		return
	}

	// Return an appropriate key.
	key = &state.ScoreMapKey{
		Path:        node.RelPath,
		Permissions: node.Info.Permissions,
		Uid:         node.Info.Uid,
		Gid:         node.Info.Gid,
		MTime:       node.Info.MTime,
		Inode:       node.Info.Inode,
		Size:        node.Info.Size,
	}

	return
}
Exemple #2
0
// Create a new inode with the supplied attributes, which need not contain
// time-related information (the inode object will take care of that).
func newInode(
	clock timeutil.Clock,
	attrs fuseops.InodeAttributes) (in *inode) {
	// Update time info.
	now := clock.Now()
	attrs.Mtime = now
	attrs.Crtime = now

	// Create the object.
	in = &inode{
		clock: clock,
		attrs: attrs,
	}

	return
}