From 676aa96f40711a42f85f6cf0d49c4c7c9f6a8ab9 Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Wed, 3 Nov 2021 16:27:37 -0700 Subject: [PATCH] Add support for overriding embedded offline.ts. Closes #1507 --- static/static.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/static/static.go b/static/static.go index a530d3e82..602f8a5d6 100644 --- a/static/static.go +++ b/static/static.go @@ -3,6 +3,8 @@ package static import ( "embed" "html/template" + "os" + "path/filepath" ) //go:embed admin/* @@ -32,5 +34,15 @@ var offlineVideoSegment []byte // GetOfflineSegment will return the offline video segment data. func GetOfflineSegment() []byte { - return offlineVideoSegment + return getFileSystemStaticFileOrDefault("offline.ts", offlineVideoSegment) +} + +func getFileSystemStaticFileOrDefault(path string, defaultData []byte) []byte { + fullPath := filepath.Join("static", path) + data, err := os.ReadFile(fullPath) //nolint: gosec + if err != nil { + return defaultData + } + + return data }