From 5a4575a93d75e7e74dd4216910b8ed5cf6c0ed3d Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sun, 28 Apr 2024 01:02:33 +0200 Subject: [PATCH] Version transcoder cache --- transcoder/utils.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/transcoder/utils.go b/transcoder/utils.go index fbf6c554..e68a6b93 100644 --- a/transcoder/utils.go +++ b/transcoder/utils.go @@ -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 {