diff --git a/server/plugin/plg_video_thumbnail/index.go b/server/plugin/plg_video_thumbnail/index.go index b77b56a12..d4bea003e 100644 --- a/server/plugin/plg_video_thumbnail/index.go +++ b/server/plugin/plg_video_thumbnail/index.go @@ -14,7 +14,7 @@ import ( ) const ( - VideoCachePath = "data/cache/video-thumbnail/" + VideoCacheTmpPath = "video-thumbnail/" ) var plugin_enable = func() bool { @@ -43,7 +43,7 @@ func init() { if plugin_enable() == false { return } - cachePath := GetAbsolutePath(VideoCachePath) + cachePath := GetAbsolutePath(TMP_PATH, VideoCacheTmpPath) os.RemoveAll(cachePath) os.MkdirAll(cachePath, os.ModePerm) @@ -63,7 +63,7 @@ func (this *ffmpegThumbnail) Generate(reader io.ReadCloser, ctx *App, res *http. "&thumbnail=true", "&origin=plg_video_thumbnail", 1, ) cacheName = "thumb_" + GenerateID(ctx.Session) + "_" + QuickHash(req.URL.Query().Get("path"), 10) + ".jpeg" - cachePath = GetAbsolutePath(VideoCachePath, cacheName) + cachePath = GetAbsolutePath(TMP_PATH, VideoCacheTmpPath, cacheName) ) reader.Close() diff --git a/server/plugin/plg_video_transcoder/index.go b/server/plugin/plg_video_transcoder/index.go index 313bcfbac..c15cbd05c 100644 --- a/server/plugin/plg_video_transcoder/index.go +++ b/server/plugin/plg_video_transcoder/index.go @@ -23,7 +23,7 @@ const ( HLS_SEGMENT_LENGTH = 5 FPS = 30 CLEAR_CACHE_AFTER = 12 - VideoCachePath = "data/cache/video/" + VideoCacheTmpPath = "video/" ) var ( @@ -79,7 +79,7 @@ func init() { blacklist_format() plugin_enable() - cachePath := GetAbsolutePath(VideoCachePath) + cachePath := GetAbsolutePath(TMP_PATH, VideoCacheTmpPath) os.RemoveAll(cachePath) os.MkdirAll(cachePath, os.ModePerm) }) @@ -129,7 +129,8 @@ func hlsPlaylistHandler(reader io.ReadCloser, ctx *App, res *http.ResponseWriter cacheName := "vid_" + GenerateID(ctx.Session) + "_" + QuickHash(path, 10) + ".dat" cachePath := GetAbsolutePath( - VideoCachePath, + TMP_PATH, + VideoCacheTmpPath, cacheName, ) f, err := os.OpenFile(cachePath, os.O_CREATE|os.O_RDWR, os.ModePerm) @@ -179,7 +180,8 @@ func hlsTranscodeHandler(ctx *App, res http.ResponseWriter, req *http.Request) { } startTime := segmentNumber * HLS_SEGMENT_LENGTH cachePath := GetAbsolutePath( - VideoCachePath, + TMP_PATH, + VideoCacheTmpPath, req.URL.Query().Get("path"), ) if _, err := os.Stat(cachePath); os.IsNotExist(err) {