From 61a75b8af3f77cf045cf71a37960efa361d09069 Mon Sep 17 00:00:00 2001 From: velvettear Date: Thu, 30 Nov 2023 16:05:35 +0100 Subject: [PATCH] removed unused code --- images/cache.go | 105 ------------------------------------------ images/history.go | 40 ---------------- images/initialize.go | 7 --- images/scaledimage.go | 31 ------------- 4 files changed, 183 deletions(-) delete mode 100644 images/cache.go delete mode 100644 images/history.go delete mode 100644 images/initialize.go delete mode 100644 images/scaledimage.go diff --git a/images/cache.go b/images/cache.go deleted file mode 100644 index a46607d..0000000 --- a/images/cache.go +++ /dev/null @@ -1,105 +0,0 @@ -package images - -// import ( -// "runtime" -// "strconv" -// "sync" -// "time" - -// "git.velvettear.de/velvettear/image-frame/config" -// "git.velvettear.de/velvettear/loggo" -// ) - -// // cache for scaled images -// var cache []scaledImage - -// // timestamp of the next cache rotation -// var NextRotation time.Time - -// // get the previous image from the history and set it as the first scaled image in the cache -// func SetPreviousImage() error { -// previousImage, error := getLatestFromHistory() -// if error != nil { -// return error -// } -// var tmpCache []scaledImage -// tmpCache = append(tmpCache, previousImage) -// tmpCache = append(tmpCache, cache...) -// cache = tmpCache -// tmpCache = nil -// return nil -// } - -// // get the first scaled image from the cache -// func GetCachedImage() scaledImage { -// return cache[0] -// } - -// // replace the first element in the cache with the last one and add a new scaled image to the cache -// func RotateCache() { -// addToHistory(GetCachedImage()) -// loggo.Debug("removing first element from image cache...") -// cacheSize := len(cache) -// if cacheSize == 1 { -// cache = nil -// cacheImages() -// return -// } -// cacheSize-- -// cache[0] = cache[cacheSize] -// cache = cache[:cacheSize] -// go cacheImages() -// } - -// // start the "slideshow" in a goroutine - rotate the cache based on the set interval -// func startSlideshow() { -// go func() { -// interval := time.Duration(config.GetImageSlideshowInterval()) * time.Second -// for { -// NextRotation = time.Now().Add(interval) -// time.Sleep(interval) -// RotateCache() -// } -// }() -// } - -// // fill the cache with scaled images -// func cacheImages() { -// timestamp := time.Now().UnixMilli() -// imageCount := len(images) -// cacheSize := len(cache) -// cacheLimit := config.GetImageCache() -// if imageCount < cacheLimit { -// cacheLimit = imageCount -// } -// imagesToCache := cacheLimit - cacheSize -// if imagesToCache <= 0 { -// return -// } -// concurrency := runtime.NumCPU() -// if imagesToCache < concurrency { -// concurrency = imagesToCache -// } -// loggo.Debug("filling image cache with "+strconv.Itoa(imagesToCache)+" element(s)", "concurrency: "+strconv.Itoa(concurrency)) -// var waitgroup sync.WaitGroup -// waitgroup.Add(imagesToCache) -// channel := make(chan struct{}, concurrency) -// var cached int -// for cached = 0; cached < imagesToCache; cached++ { -// channel <- struct{}{} -// var randomScaledImage scaledImage -// randomScaledImage.Name = getRandomImage() -// if randomScaledImage.isCached() { -// continue -// } -// go func(randomScaledImage scaledImage) { -// randomScaledImage.Data = scale(randomScaledImage.Name, config.GetImageWidth(), config.GetImageHeight()) -// cache = append(cache, randomScaledImage) -// loggo.Debug("added scaled image '" + randomScaledImage.Name + "' to cache") -// <-channel -// waitgroup.Done() -// }(randomScaledImage) -// } -// waitgroup.Wait() -// loggo.DebugTimed("filled image cache with "+strconv.Itoa(cached)+" images", timestamp) -// } diff --git a/images/history.go b/images/history.go deleted file mode 100644 index 6d27307..0000000 --- a/images/history.go +++ /dev/null @@ -1,40 +0,0 @@ -package images - -// import ( -// "errors" -// "strconv" -// "time" - -// "git.velvettear.de/velvettear/image-frame/config" -// "git.velvettear.de/velvettear/loggo" -// ) - -// // internal history of displayed images -// var history []scaledImage - -// // add a image to the history -// func addToHistory(scaledImage scaledImage) { -// timestamp := time.Now().UnixMilli() -// historyLimit := config.GetImageSlideshowHistory() -// if historyLimit <= 0 { -// return -// } -// history = append(history, scaledImage) -// diff := len(history) - historyLimit -// if diff > 0 { -// history = history[diff:] -// } -// loggo.DebugTimed("added image to history", timestamp, "history size: "+strconv.Itoa(len(history))) -// } - -// // get and remove the latest image from history -// func getLatestFromHistory() (scaledImage, error) { -// var scaledImage scaledImage -// if len(history) == 0 { -// return scaledImage, errors.New("history is empty") -// } -// index := len(history) - 1 -// scaledImage = history[index] -// history = history[:index] -// return scaledImage, nil -// } diff --git a/images/initialize.go b/images/initialize.go deleted file mode 100644 index ac105ce..0000000 --- a/images/initialize.go +++ /dev/null @@ -1,7 +0,0 @@ -package images - -// func Initialize() { -// scanForImages() -// cacheImages() -// startSlideshow() -// } diff --git a/images/scaledimage.go b/images/scaledimage.go deleted file mode 100644 index 6d85093..0000000 --- a/images/scaledimage.go +++ /dev/null @@ -1,31 +0,0 @@ -package images - -// import ( -// "math/rand" -// ) - -// // struct for scaled images -// type scaledImage struct { -// Name string -// Data []byte -// } - -// // get a random image -// func getRandomImage() string { -// return images[rand.Intn(len(images)-1)] -// } - -// // check if the scaled image is already cached -// func (scaledImage *scaledImage) isCached() bool { -// return isCached(scaledImage.Name) -// } - -// // check (by name) if the scaled image is already cached -// func isCached(scaledImageName string) bool { -// for _, cachedImage := range cache { -// if cachedImage.Name == scaledImageName { -// return true -// } -// } -// return false -// }