Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
Alexander Onnikov
2025-05-30 22:29:39 +07:00
parent d2f20a5acc
commit faeca99748
5 changed files with 15 additions and 13 deletions
+1 -1
View File
@@ -61,7 +61,7 @@ linters-settings:
dupl:
threshold: 150
funlen:
lines: 160
lines: 180
statements: 100
goconst:
min-len: 2
+5 -5
View File
@@ -24,7 +24,7 @@ import (
func Test_BuildVideoCommand_Scaling(t *testing.T) {
var scaleCommand = mediaconvert.BuildScalingVideoCommand(&mediaconvert.Options{
OutputDir: "test",
OutputDir: "test",
Input: "pipe:0",
UploadID: "1",
Threads: 4,
@@ -39,10 +39,10 @@ func Test_BuildVideoCommand_Scaling(t *testing.T) {
func Test_BuildVideoCommand_Raw(t *testing.T) {
var rawCommand = mediaconvert.BuildRawVideoCommand(&mediaconvert.Options{
OutputDir: "test",
Input: "pipe:0",
UploadID: "1",
Threads: 4,
Level: resconv.Level("651:490"),
Input: "pipe:0",
UploadID: "1",
Threads: 4,
Level: resconv.Level("651:490"),
})
const expected = `"-threads 4 -i pipe:0 -c:a copy -c:v copy -hls_time 5 -hls_flags split_by_time -hls_list_size 0 -hls_segment_filename test/1/1_%03d_480p.ts test/1/1_480p_master.m3u8`
+1 -1
View File
@@ -97,7 +97,7 @@ func (s *StreamCoordinator) NewUpload(ctx context.Context, info handler.FileInfo
var commandOptions = Options{
Input: "pipe:0",
OutputDir: s.conf.OutputDir,
OutputDir: s.conf.OutputDir,
Threads: s.conf.MaxThreadCount,
UploadID: info.ID,
Level: level,
+2 -2
View File
@@ -128,7 +128,7 @@ func (p *Scheduler) processTask(ctx context.Context, task *Task) {
}
defer func() {
if err := os.RemoveAll(destinationFolder); err != nil {
if err = os.RemoveAll(destinationFolder); err != nil {
logger.Error("failed to cleanup temporary folder", zap.Error(err))
}
}()
@@ -182,7 +182,7 @@ func (p *Scheduler) processTask(ctx context.Context, task *Task) {
var level = resconv.Level(res)
var opts = Options{
Input: sourceFilePath,
OutputDir: p.cfg.OutputDir,
OutputDir: p.cfg.OutputDir,
Level: level,
ScalingLevels: append(resconv.SubLevels(res), level),
UploadID: task.ID,
+6 -4
View File
@@ -133,7 +133,6 @@ func (u *uploaderImpl) scanInitialFiles() {
u.logger.Info("initial file scan complete", zap.String("dir", u.options.Dir), zap.Int("count", len(initFiles)))
}()
}
func (u *uploaderImpl) stop(rollback bool) {
@@ -276,7 +275,6 @@ func (u *uploaderImpl) uploadAndDelete(f string) {
}
}
break
}
@@ -295,9 +293,13 @@ func (u *uploaderImpl) startWatch(ready chan<- struct{}) {
close(ready)
return
}
defer watcher.Close()
defer func() {
if err := watcher.Close(); err != nil {
logger.Error("can not close watcher", zap.Error(err))
}
}()
if err := watcher.AddWatch(u.options.Dir, inotifyCloseWrite | inotifyMovedTo); err != nil {
if err := watcher.AddWatch(u.options.Dir, inotifyCloseWrite|inotifyMovedTo); err != nil {
logger.Error("can not start watching", zap.Error(err))
close(ready)
return