mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 20:34:37 +03:00
Add a cache for gallery thumbnails (#496)
This commit is contained in:
@@ -1,12 +1,18 @@
|
||||
package paths
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/stashapp/stash/pkg/manager/config"
|
||||
"github.com/stashapp/stash/pkg/utils"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
type galleryPaths struct{}
|
||||
|
||||
const thumbDir = "gthumbs"
|
||||
const thumbDirDepth int = 2
|
||||
const thumbDirLength int = 2 // thumbDirDepth * thumbDirLength must be smaller than the length of checksum
|
||||
|
||||
func newGalleryPaths() *galleryPaths {
|
||||
return &galleryPaths{}
|
||||
}
|
||||
@@ -15,6 +21,19 @@ func (gp *galleryPaths) GetExtractedPath(checksum string) string {
|
||||
return filepath.Join(config.GetCachePath(), checksum)
|
||||
}
|
||||
|
||||
func GetGthumbCache() string {
|
||||
return filepath.Join(config.GetCachePath(), thumbDir)
|
||||
}
|
||||
|
||||
func GetGthumbDir(checksum string) string {
|
||||
return filepath.Join(config.GetCachePath(), thumbDir, utils.GetIntraDir(checksum, thumbDirDepth, thumbDirLength), checksum)
|
||||
}
|
||||
|
||||
func GetGthumbPath(checksum string, index int, width int) string {
|
||||
fname := fmt.Sprintf("%s_%d_%d.jpg", checksum, index, width)
|
||||
return filepath.Join(config.GetCachePath(), thumbDir, utils.GetIntraDir(checksum, thumbDirDepth, thumbDirLength), checksum, fname)
|
||||
}
|
||||
|
||||
func (gp *galleryPaths) GetExtractedFilePath(checksum string, fileName string) string {
|
||||
return filepath.Join(config.GetCachePath(), checksum, fileName)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user