From 10bb9a6abc01276cf98349bc65178cb6506a6cbc Mon Sep 17 00:00:00 2001 From: kermieisinthehouse Date: Wed, 2 Feb 2022 16:58:48 -0800 Subject: [PATCH] Delete funscripts while deleting scene (#2265) * Delete funscripts while deleting scene * Indicate that funscripts will be deleted Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com> --- pkg/scene/delete.go | 8 +++++ .../components/Changelog/versions/v0130.md | 1 + .../components/Scenes/DeleteScenesDialog.tsx | 30 +++++++++++++++---- ui/v2.5/src/locales/en-GB.json | 1 + 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/pkg/scene/delete.go b/pkg/scene/delete.go index 57802d0cb..63672eecb 100644 --- a/pkg/scene/delete.go +++ b/pkg/scene/delete.go @@ -135,6 +135,14 @@ func Destroy(scene *models.Scene, repo models.Repository, fileDeleter *FileDelet if err := fileDeleter.Files([]string{scene.Path}); err != nil { return err } + + funscriptPath := utils.GetFunscriptPath(scene.Path) + funscriptExists, _ := utils.FileExists(funscriptPath) + if funscriptExists { + if err := fileDeleter.Files([]string{funscriptPath}); err != nil { + return err + } + } } if deleteGenerated { diff --git a/ui/v2.5/src/components/Changelog/versions/v0130.md b/ui/v2.5/src/components/Changelog/versions/v0130.md index e2a369c95..342bf0c5a 100644 --- a/ui/v2.5/src/components/Changelog/versions/v0130.md +++ b/ui/v2.5/src/components/Changelog/versions/v0130.md @@ -11,6 +11,7 @@ * Show counts on list tabs in Performer, Studio and Tag pages. ([#2169](https://github.com/stashapp/stash/pull/2169)) ### 🐛 Bug fixes +* Delete funscripts when deleting scene files. ([#2265](https://github.com/stashapp/stash/pull/2265)) * Removed trusted proxies setting. ([#2229](https://github.com/stashapp/stash/pull/2229)) * Allow Stash to be iframed. ([#2217](https://github.com/stashapp/stash/pull/2217)) * Resolve CDP hostname if necessary. ([#2174](https://github.com/stashapp/stash/pull/2174)) diff --git a/ui/v2.5/src/components/Scenes/DeleteScenesDialog.tsx b/ui/v2.5/src/components/Scenes/DeleteScenesDialog.tsx index fc0859821..6534ac1ba 100644 --- a/ui/v2.5/src/components/Scenes/DeleteScenesDialog.tsx +++ b/ui/v2.5/src/components/Scenes/DeleteScenesDialog.tsx @@ -67,11 +67,29 @@ export const DeleteScenesDialog: React.FC = ( props.onClose(true); } + function funscriptPath(scenePath: string) { + const extIndex = scenePath.lastIndexOf("."); + if (extIndex !== -1) { + return scenePath.substring(0, extIndex + 1) + "funscript"; + } + + return scenePath; + } + function maybeRenderDeleteFileAlert() { if (!deleteFile) { return; } + const deletedFiles: string[] = []; + + props.selected.forEach((s) => { + deletedFiles.push(s.path); + if (s.interactive) { + deletedFiles.push(funscriptPath(s.path)); + } + }); + return (

@@ -85,13 +103,13 @@ export const DeleteScenesDialog: React.FC = ( />

    - {props.selected.slice(0, 5).map((s) => ( -
  • {s.path}
  • + {deletedFiles.slice(0, 5).map((s) => ( +
  • {s}
  • ))} - {props.selected.length > 5 && ( + {deletedFiles.length > 5 && ( = ( setDeleteFile(!deleteFile)} />