Add move files external interface (#3557)

* Add moveFiles graphql mutation
* Move library resolution code into config
* Implement file moving
* Log if old file not removed in SafeMove
* Ensure extensions are consistent
* Don't allow overwriting existing files
This commit is contained in:
WithoutPants
2023-03-22 07:57:26 +11:00
committed by GitHub
parent f6387c1018
commit 09c724b8d5
12 changed files with 436 additions and 50 deletions

View File

@@ -7,6 +7,8 @@ import (
"path/filepath"
"regexp"
"strings"
"github.com/stashapp/stash/pkg/logger"
)
// SafeMove attempts to move the file with path src to dest using os.Rename. If this fails, then it copies src to dest, then deletes src.
@@ -38,7 +40,7 @@ func SafeMove(src, dst string) error {
err = os.Remove(src)
if err != nil {
return err
logger.Errorf("error removing old file %s during SafeMove: %v", src, err)
}
}