Add golangci-lint config
This commit is contained in:
@@ -2,6 +2,7 @@ package cacher
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -10,7 +11,7 @@ import (
|
||||
"source.hodakov.me/hdkv/faketunes/internal/domains/cacher/models"
|
||||
)
|
||||
|
||||
// getStat returns file size without triggering conversion (for ls/stat)
|
||||
// getStat returns file size without triggering conversion (for ls/stat).
|
||||
func (c *Cacher) GetStat(sourcePath string) (int64, error) {
|
||||
c.statMutex.RLock()
|
||||
defer c.statMutex.RUnlock()
|
||||
@@ -28,7 +29,7 @@ func (c *Cacher) GetStat(sourcePath string) (int64, error) {
|
||||
|
||||
keyData := fmt.Sprintf("%s:%d", sourcePath, info.ModTime().UnixNano())
|
||||
hash := md5.Sum([]byte(keyData))
|
||||
key := fmt.Sprintf("%x", hash)
|
||||
key := hex.EncodeToString(hash[:])
|
||||
cachePath := filepath.Join(c.cacheDir, key+".m4a")
|
||||
|
||||
// Check if converted file exists and is valid
|
||||
@@ -44,7 +45,7 @@ func (c *Cacher) GetStat(sourcePath string) (int64, error) {
|
||||
return info.Size(), nil
|
||||
}
|
||||
|
||||
// updateCachedStat updates the stat cache
|
||||
// updateCachedStat updates the stat cache.
|
||||
func (c *Cacher) updateCachedStat(sourcePath string, size int64) {
|
||||
c.statMutex.Lock()
|
||||
defer c.statMutex.Unlock()
|
||||
@@ -55,7 +56,7 @@ func (c *Cacher) updateCachedStat(sourcePath string, size int64) {
|
||||
}
|
||||
}
|
||||
|
||||
// getCachedStat returns cached file stats
|
||||
// getCachedStat returns cached file stats.
|
||||
func (c *Cacher) getCachedStat(sourcePath string) (int64, bool) {
|
||||
c.statMutex.RLock()
|
||||
defer c.statMutex.RUnlock()
|
||||
@@ -63,5 +64,6 @@ func (c *Cacher) getCachedStat(sourcePath string) (int64, bool) {
|
||||
if stat, ok := c.stat[sourcePath]; ok {
|
||||
return stat.Size, true
|
||||
}
|
||||
|
||||
return 0, false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user