From 0472f9a8ed6dec556c231432ebd04600d78e76d2 Mon Sep 17 00:00:00 2001 From: Stash Dev Date: Sun, 10 Feb 2019 10:13:23 -0800 Subject: [PATCH] Fixed weird windows path issue --- database/database.go | 8 ++------ ffmpeg/encoder_scene_preview_chunk.go | 3 ++- utils/windows.go | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 utils/windows.go diff --git a/database/database.go b/database/database.go index f6f448cbb..590e29341 100644 --- a/database/database.go +++ b/database/database.go @@ -8,8 +8,7 @@ import ( "github.com/jmoiron/sqlx" _ "github.com/mattn/go-sqlite3" "github.com/stashapp/stash/logger" - "runtime" - "strings" + "github.com/stashapp/stash/utils" ) var DB *sqlx.DB @@ -44,10 +43,7 @@ func runMigrations(databasePath string) { Migrations: source.NewMigrations(), } - // Golang migrate has an issue where the \ isn't recognized as a valid on windows - if runtime.GOOS == "windows" { - databasePath = strings.Replace(databasePath, "\\", "/", -1) - } + databasePath = utils.FixWindowsPath(databasePath) s, _ := WithInstance(packrSource) m, err := migrate.NewWithSourceInstance( "packr2", diff --git a/ffmpeg/encoder_scene_preview_chunk.go b/ffmpeg/encoder_scene_preview_chunk.go index 5d5d420c3..998608009 100644 --- a/ffmpeg/encoder_scene_preview_chunk.go +++ b/ffmpeg/encoder_scene_preview_chunk.go @@ -2,6 +2,7 @@ package ffmpeg import ( "fmt" + "github.com/stashapp/stash/utils" "strconv" ) @@ -36,7 +37,7 @@ func (e *Encoder) ScenePreviewVideoChunkCombine(probeResult VideoFile, concatFil args := []string{ "-v", "quiet", "-f", "concat", - "-i", concatFilePath, + "-i", utils.FixWindowsPath(concatFilePath), "-y", "-c", "copy", outputPath, diff --git a/utils/windows.go b/utils/windows.go new file mode 100644 index 000000000..43a23d900 --- /dev/null +++ b/utils/windows.go @@ -0,0 +1,15 @@ +package utils + +import ( + "runtime" + "strings" +) + +// Sometimes the \ isn't recognized as valid on windows +func FixWindowsPath(str string) string { + if runtime.GOOS == "windows" { + return strings.Replace(str, "\\", "/", -1) + } else { + return str + } +} \ No newline at end of file