Skip to content

Commit eb1f10c

Browse files
committed
plg_video_{thumbnail,transcoder}: use common cache directory
1 parent 2b872a0 commit eb1f10c

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

server/plugin/plg_video_thumbnail/index.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
)
1515

1616
const (
17-
VideoCachePath = "data/cache/video-thumbnail/"
17+
VideoCacheTmpPath = "video-thumbnail/"
1818
)
1919

2020
var plugin_enable = func() bool {
@@ -43,7 +43,7 @@ func init() {
4343
if plugin_enable() == false {
4444
return
4545
}
46-
cachePath := GetAbsolutePath(VideoCachePath)
46+
cachePath := GetAbsolutePath(TMP_PATH, VideoCacheTmpPath)
4747
os.RemoveAll(cachePath)
4848
os.MkdirAll(cachePath, os.ModePerm)
4949

@@ -63,7 +63,7 @@ func (this *ffmpegThumbnail) Generate(reader io.ReadCloser, ctx *App, res *http.
6363
"&thumbnail=true", "&origin=plg_video_thumbnail", 1,
6464
)
6565
cacheName = "thumb_" + GenerateID(ctx.Session) + "_" + QuickHash(req.URL.Query().Get("path"), 10) + ".jpeg"
66-
cachePath = GetAbsolutePath(VideoCachePath, cacheName)
66+
cachePath = GetAbsolutePath(TMP_PATH, VideoCacheTmpPath, cacheName)
6767
)
6868

6969
reader.Close()

server/plugin/plg_video_transcoder/index.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const (
2323
HLS_SEGMENT_LENGTH = 5
2424
FPS = 30
2525
CLEAR_CACHE_AFTER = 12
26-
VideoCachePath = "data/cache/video/"
26+
VideoCacheTmpPath = "video/"
2727
)
2828

2929
var (
@@ -79,7 +79,7 @@ func init() {
7979
blacklist_format()
8080
plugin_enable()
8181

82-
cachePath := GetAbsolutePath(VideoCachePath)
82+
cachePath := GetAbsolutePath(TMP_PATH, VideoCacheTmpPath)
8383
os.RemoveAll(cachePath)
8484
os.MkdirAll(cachePath, os.ModePerm)
8585
})
@@ -129,7 +129,8 @@ func hlsPlaylistHandler(reader io.ReadCloser, ctx *App, res *http.ResponseWriter
129129

130130
cacheName := "vid_" + GenerateID(ctx.Session) + "_" + QuickHash(path, 10) + ".dat"
131131
cachePath := GetAbsolutePath(
132-
VideoCachePath,
132+
TMP_PATH,
133+
VideoCacheTmpPath,
133134
cacheName,
134135
)
135136
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) {
179180
}
180181
startTime := segmentNumber * HLS_SEGMENT_LENGTH
181182
cachePath := GetAbsolutePath(
182-
VideoCachePath,
183+
TMP_PATH,
184+
VideoCacheTmpPath,
183185
req.URL.Query().Get("path"),
184186
)
185187
if _, err := os.Stat(cachePath); os.IsNotExist(err) {

0 commit comments

Comments
 (0)