From 99dca8b42cf3768b493c35ab06c650723c7c2661 Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Fri, 27 Feb 2015 14:24:31 +1100 Subject: [PATCH] Refactored attribute patching. --- samples/hello_fs.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/samples/hello_fs.go b/samples/hello_fs.go index e755702..28a7724 100644 --- a/samples/hello_fs.go +++ b/samples/hello_fs.go @@ -116,6 +116,14 @@ func findChildInode( return } +func (fs *HelloFS) patchAttributes( + attr *fuse.InodeAttributes) { + now := fs.Clock.Now() + attr.Atime = now + attr.Mtime = now + attr.Crtime = now +} + func (fs *HelloFS) LookUpInode( ctx context.Context, req *fuse.LookUpInodeRequest) ( @@ -140,10 +148,7 @@ func (fs *HelloFS) LookUpInode( resp.Attributes = gInodeInfo[childInode].attributes // Patch attributes. - now := fs.Clock.Now() - resp.Attributes.Atime = now - resp.Attributes.Mtime = now - resp.Attributes.Crtime = now + fs.patchAttributes(&resp.Attributes) return } @@ -165,10 +170,7 @@ func (fs *HelloFS) GetInodeAttributes( resp.Attributes = info.attributes // Patch attributes. - now := fs.Clock.Now() - resp.Attributes.Atime = now - resp.Attributes.Mtime = now - resp.Attributes.Crtime = now + fs.patchAttributes(&resp.Attributes) return }