Version transcoder cache

This commit is contained in:
Zoe Roux 2024-04-28 01:02:33 +02:00
parent 2eecb5174c
commit 5a4575a93d
No known key found for this signature in database

View File

@ -16,6 +16,11 @@ import (
var safe_path = src.GetEnvOr("GOCODER_SAFE_PATH", "/video")
// Encode the version in the hash path to update cached values.
// Older versions won't be deleted (needed to allow multiples versions of the transcoder to run at the same time)
// If the version changes a lot, we might want to automatically delete older versions.
var version = "v1."
func GetPath(c echo.Context) (string, string, error) {
key := c.Param("path")
if key == "" {
@ -49,7 +54,7 @@ func getHash(path string) (string, error) {
h.Write([]byte(path))
h.Write([]byte(info.ModTime().String()))
sha := hex.EncodeToString(h.Sum(nil))
return sha, nil
return version + sha, nil
}
func SanitizePath(path string) error {