From 3195223e8231e5981b3f16e8d77855ec4a961c87 Mon Sep 17 00:00:00 2001 From: aditya-K2 Date: Fri, 26 Nov 2021 21:59:50 +0530 Subject: [PATCH] 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. --- cache/cache.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cache/cache.go b/cache/cache.go index dc6b84f..80eba89 100644 --- a/cache/cache.go +++ b/cache/cache.go @@ -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