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

@@ -164,9 +164,9 @@ func (f *cleanFilter) Accept(ctx context.Context, path string, info fs.FileInfo)
if info.IsDir() {
fileOrFolder = "Folder"
stash = getStashFromDirPath(f.stashPaths, path)
stash = f.stashPaths.GetStashFromDirPath(path)
} else {
stash = getStashFromPath(f.stashPaths, path)
stash = f.stashPaths.GetStashFromPath(path)
}
if stash == nil {
@@ -449,21 +449,3 @@ func (h *cleanHandler) handleRelatedImages(ctx context.Context, fileDeleter *fil
return nil
}
func getStashFromPath(stashes []*config.StashConfig, pathToCheck string) *config.StashConfig {
for _, f := range stashes {
if fsutil.IsPathInDir(f.Path, filepath.Dir(pathToCheck)) {
return f
}
}
return nil
}
func getStashFromDirPath(stashes []*config.StashConfig, pathToCheck string) *config.StashConfig {
for _, f := range stashes {
if fsutil.IsPathInDir(f.Path, pathToCheck) {
return f
}
}
return nil
}