Use a subdir in cache to ensure no user data is ever deleted (#770)

This commit is contained in:
Zoe Roux 2025-01-09 21:33:51 +01:00 committed by GitHub
parent dcd7e8fad8
commit f59dd37825
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 2 deletions

View File

@ -1,6 +1,9 @@
package src
import "os"
import (
"os"
"path"
)
func GetEnvOr(env string, def string) string {
out := os.Getenv(env)
@ -26,7 +29,8 @@ type HwAccelT struct {
}
var Settings = SettingsT{
Outpath: GetEnvOr("GOCODER_CACHE_ROOT", "/cache"),
// we manually add a folder to make sure we do not delete user data.
Outpath: path.Join(GetEnvOr("GOCODER_CACHE_ROOT", "/cache"), "kyoo_cache"),
Metadata: GetEnvOr("GOCODER_METADATA_ROOT", "/metadata"),
RoutePrefix: GetEnvOr("GOCODER_PREFIX", ""),
SafePath: GetEnvOr("GOCODER_SAFE_PATH", "/video"),

View File

@ -15,6 +15,7 @@ type Transcoder struct {
func NewTranscoder(metadata *MetadataService) (*Transcoder, error) {
out := Settings.Outpath
os.MkdirAll(out, 0o755)
dir, err := os.ReadDir(out)
if err != nil {
return nil, err