Added Functionality to Point path to default Img

Sometimes the image is not found and for those artist/albums there is no
way for pointing the image path to default image path so some helper
functions have been added so that we can point them to default Image.
This commit is contained in:
aditya-K2 2021-11-26 21:59:50 +05:30
parent 7da86291dc
commit 3195223e82
1 changed files with 9 additions and 0 deletions

9
cache/cache.go vendored
View File

@ -12,12 +12,17 @@ var (
USER_CACHE_DIR, err = os.UserCacheDir()
CACHE_LIST map[[2]string]string = make(map[[2]string]string)
CACHE_DIR string = USER_CACHE_DIR
DEFAULT_IMG string
)
func SetCacheDir(path string) {
CACHE_DIR = path
}
func SetDefaultPath(path string) {
DEFAULT_IMG = path
}
func LoadCache(path string) error {
cacheFileContent, err := ioutil.ReadFile(path)
if err != nil {
@ -43,6 +48,10 @@ func GetFromCache(artist, album string) (string, error) {
}
}
func PointToDefault(artist, album string) {
CACHE_LIST[[2]string{artist, album}] = DEFAULT_IMG
}
func AddToCache(artist, album string) string {
fileName := CACHE_DIR + GenerateName(artist, album)
CACHE_LIST[[2]string{artist, album}] = fileName