From fd1ec31a1dcf1dc38fbb59fd01405c82fdd90511 Mon Sep 17 00:00:00 2001 From: Emil Sit Date: Sat, 20 Jul 2013 00:15:14 -0400 Subject: [PATCH] packer/cache: Extract cache path calculation to method --- packer/cache.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packer/cache.go b/packer/cache.go index 6f8d14134..6c2ed0207 100644 --- a/packer/cache.go +++ b/packer/cache.go @@ -44,7 +44,7 @@ func (f *FileCache) Lock(key string) string { rw := f.rwLock(hashKey) rw.Lock() - return filepath.Join(f.CacheDir, hashKey) + return f.cachePath(key, hashKey) } func (f *FileCache) Unlock(key string) { @@ -58,7 +58,7 @@ func (f *FileCache) RLock(key string) (string, bool) { rw := f.rwLock(hashKey) rw.RLock() - return filepath.Join(f.CacheDir, hashKey), true + return f.cachePath(key, hashKey), true } func (f *FileCache) RUnlock(key string) { @@ -67,6 +67,10 @@ func (f *FileCache) RUnlock(key string) { rw.RUnlock() } +func (f *FileCache) cachePath(key string, hashKey string) string { + return filepath.Join(f.CacheDir, hashKey) +} + func (f *FileCache) hashKey(key string) string { sha := sha256.New() sha.Write([]byte(key))