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:
		
							parent
							
								
									7da86291dc
								
							
						
					
					
						commit
						3195223e82
					
				
							
								
								
									
										9
									
								
								cache/cache.go
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										9
									
								
								cache/cache.go
									
									
									
									
										vendored
									
									
								
							@ -12,12 +12,17 @@ var (
 | 
				
			|||||||
	USER_CACHE_DIR, err                      = os.UserCacheDir()
 | 
						USER_CACHE_DIR, err                      = os.UserCacheDir()
 | 
				
			||||||
	CACHE_LIST          map[[2]string]string = make(map[[2]string]string)
 | 
						CACHE_LIST          map[[2]string]string = make(map[[2]string]string)
 | 
				
			||||||
	CACHE_DIR           string               = USER_CACHE_DIR
 | 
						CACHE_DIR           string               = USER_CACHE_DIR
 | 
				
			||||||
 | 
						DEFAULT_IMG         string
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func SetCacheDir(path string) {
 | 
					func SetCacheDir(path string) {
 | 
				
			||||||
	CACHE_DIR = path
 | 
						CACHE_DIR = path
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func SetDefaultPath(path string) {
 | 
				
			||||||
 | 
						DEFAULT_IMG = 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 {
 | 
				
			||||||
@ -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 {
 | 
					func AddToCache(artist, album string) string {
 | 
				
			||||||
	fileName := CACHE_DIR + GenerateName(artist, album)
 | 
						fileName := CACHE_DIR + GenerateName(artist, album)
 | 
				
			||||||
	CACHE_LIST[[2]string{artist, album}] = fileName
 | 
						CACHE_LIST[[2]string{artist, album}] = fileName
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user