diff --git a/internal/tasks/video.go b/internal/tasks/video.go index ca3c8bd..c551931 100644 --- a/internal/tasks/video.go +++ b/internal/tasks/video.go @@ -174,6 +174,12 @@ func (w PostProcessVideoWorker) Work(ctx context.Context, job *river.Job[PostPro // convert to HLS if needed if config.Get().Archive.SaveAsHls { + // create temp hls directory + if err := utils.CreateDirectory(dbItems.Video.TmpVideoHlsPath); err != nil { + return err + } + + // convert to hls err = exec.ConvertVideoToHLS(ctx, dbItems.Video) if err != nil { return err @@ -284,6 +290,18 @@ func (w MoveVideoWorker) Work(ctx context.Context, job *river.Job[MoveVideoArgs] if err != nil { return err } + + // clean up temp hls directory + if err := utils.DeleteDirectory(dbItems.Video.TmpVideoHlsPath); err != nil { + return err + } + // delete temp converted video + if utils.FileExists(dbItems.Video.TmpVideoConvertPath) { + err = utils.DeleteFile(dbItems.Video.TmpVideoConvertPath) + if err != nil { + return err + } + } } // set queue status to completed diff --git a/internal/utils/file.go b/internal/utils/file.go index 6d6c07b..19626bf 100644 --- a/internal/utils/file.go +++ b/internal/utils/file.go @@ -281,7 +281,6 @@ func MoveFolder(src string, dst string) error { } func DeleteFile(path string) error { - log.Debug().Msgf("deleting file: %s", path) err := os.Remove(path) if err != nil { return err diff --git a/internal/vod/vod.go b/internal/vod/vod.go index 8f979d9..b8cedcd 100644 --- a/internal/vod/vod.go +++ b/internal/vod/vod.go @@ -202,7 +202,7 @@ func (s *Service) DeleteVod(c echo.Context, vodID uuid.UUID, deleteFiles bool) e return err } } - if err := utils.DeleteFile(v.TmpVideoHlsPath); err != nil { + if err := utils.DeleteDirectory(v.TmpVideoHlsPath); err != nil { if errors.Is(err, os.ErrNotExist) { log.Debug().Msgf("temp file %s does not exist", v.TmpVideoHlsPath) } else { diff --git a/nginx.conf b/nginx.conf index e545803..11a2cd4 100644 --- a/nginx.conf +++ b/nginx.conf @@ -27,7 +27,7 @@ http { add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always; add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always; - location ^~ /videos { + location ^~ /data/videos { autoindex on; alias /mnt/videos;