Added Simple Helper Functions
Following Functions have been added : 1. SetCacheDir : Sets the Cache Directory 2. CHANGE AddToCache the image path is now the Cache Directory + image Path
This commit is contained in:
parent
42832491d0
commit
1014981dcb
14
cache/cache.go
vendored
14
cache/cache.go
vendored
@ -9,9 +9,15 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
CACHE_LIST map[[2]string]string = make(map[[2]string]string)
|
USER_CACHE_DIR, err = os.UserCacheDir()
|
||||||
|
CACHE_LIST map[[2]string]string = make(map[[2]string]string)
|
||||||
|
CACHE_DIR string = USER_CACHE_DIR
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func SetCacheDir(path string) {
|
||||||
|
CACHE_DIR = path
|
||||||
|
}
|
||||||
|
|
||||||
func LoadCache(path string) error {
|
func LoadCache(path string) error {
|
||||||
cacheFileContent, err := ioutil.ReadFile(path)
|
cacheFileContent, err := ioutil.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -37,8 +43,10 @@ func GetFromCache(artist, album string) (string, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func AddToCache(artist, album string) {
|
func AddToCache(artist, album string) string {
|
||||||
CACHE_LIST[[2]string{artist, album}] = GenerateName(artist, album)
|
fileName := CACHE_DIR + GenerateName(artist, album)
|
||||||
|
CACHE_LIST[[2]string{artist, album}] = fileName
|
||||||
|
return fileName
|
||||||
}
|
}
|
||||||
|
|
||||||
func WriteCache(path string) {
|
func WriteCache(path string) {
|
||||||
|
Loading…
Reference in New Issue
Block a user