Add: tmpfs lock and fix bug

This commit is contained in:
2021-12-14 01:19:50 +08:00
parent 922b2370ee
commit 47b178ac90
2 changed files with 38 additions and 6 deletions

View File

@@ -142,8 +142,10 @@ func (api *API) HandlePrepareFileStreamDirect(w http.ResponseWriter, r *http.Req
json.NewEncoder(w).Encode(prepareFileStreamDirectResponse)
return
}
// lock the object
api.Tmpfs.Lock(objPath)
api.Tmpfs.Record(objPath)
args := strings.Split(ffmpegConfig.Args, " ")
startArgs := []string{"-threads", strconv.FormatInt(api.APIConfig.FfmpegThreads, 10), "-i", srcPath}
endArgs := []string{"-vn", "-y", objPath}
@@ -156,6 +158,9 @@ func (api *API) HandlePrepareFileStreamDirect(w http.ResponseWriter, r *http.Req
return
}
api.Tmpfs.Record(objPath)
api.Tmpfs.Unlock(objPath)
fileInfo, err := os.Stat(objPath)
if err != nil {
api.HandleError(w, r, err)