Files
stash/pkg/manager/paths/paths_generated.go
WithoutPants f6ffda7504 Setup and migration UI refactor (#1190)
* Make config instance-based
* Remove config dependency in paths
* Refactor config init
* Allow startup without database
* Get system status at UI initialise
* Add setup wizard
* Cache and Metadata optional. Database mandatory
* Handle metadata not set during full import/export
* Add links
* Remove config check middleware
* Stash not mandatory
* Panic on missing mandatory config fields
* Redirect setup to main page if setup not required
* Add migration UI
* Remove unused stuff
* Move UI initialisation into App
* Don't create metadata paths on RefreshConfig
* Add folder selector for generated in setup
* Env variable to set and create config file.
Make docker images use a fixed config file.
* Set config file during setup
2021-04-12 09:31:33 +10:00

68 lines
1.6 KiB
Go

package paths
import (
"fmt"
"io/ioutil"
"path/filepath"
"github.com/stashapp/stash/pkg/utils"
)
const thumbDirDepth int = 2
const thumbDirLength int = 2 // thumbDirDepth * thumbDirLength must be smaller than the length of checksum
type generatedPaths struct {
Screenshots string
Thumbnails string
Vtt string
Markers string
Transcodes string
Downloads string
Tmp string
}
func newGeneratedPaths(path string) *generatedPaths {
gp := generatedPaths{}
gp.Screenshots = filepath.Join(path, "screenshots")
gp.Thumbnails = filepath.Join(path, "thumbnails")
gp.Vtt = filepath.Join(path, "vtt")
gp.Markers = filepath.Join(path, "markers")
gp.Transcodes = filepath.Join(path, "transcodes")
gp.Downloads = filepath.Join(path, "download_stage")
gp.Tmp = filepath.Join(path, "tmp")
return &gp
}
func (gp *generatedPaths) GetTmpPath(fileName string) string {
return filepath.Join(gp.Tmp, fileName)
}
func (gp *generatedPaths) EnsureTmpDir() {
utils.EnsureDir(gp.Tmp)
}
func (gp *generatedPaths) EmptyTmpDir() {
utils.EmptyDir(gp.Tmp)
}
func (gp *generatedPaths) RemoveTmpDir() {
utils.RemoveDir(gp.Tmp)
}
func (gp *generatedPaths) TempDir(pattern string) (string, error) {
gp.EnsureTmpDir()
ret, err := ioutil.TempDir(gp.Tmp, pattern)
if err != nil {
return "", err
}
utils.EmptyDir(ret)
return ret, nil
}
func (gp *generatedPaths) GetThumbnailPath(checksum string, width int) string {
fname := fmt.Sprintf("%s_%d.jpg", checksum, width)
return filepath.Join(gp.Thumbnails, utils.GetIntraDir(checksum, thumbDirDepth, thumbDirLength), fname)
}