Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete funscripts while deleting scene #2265

Merged
merged 4 commits into from
Feb 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pkg/scene/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions ui/v2.5/src/components/Changelog/versions/v0130.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
30 changes: 25 additions & 5 deletions ui/v2.5/src/components/Scenes/DeleteScenesDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,29 @@ export const DeleteScenesDialog: React.FC<IDeleteSceneDialogProps> = (
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 (
<div className="delete-dialog alert alert-danger text-break">
<p className="font-weight-bold">
Expand All @@ -85,13 +103,13 @@ export const DeleteScenesDialog: React.FC<IDeleteSceneDialogProps> = (
/>
</p>
<ul>
{props.selected.slice(0, 5).map((s) => (
<li key={s.path}>{s.path}</li>
{deletedFiles.slice(0, 5).map((s) => (
<li key={s}>{s}</li>
))}
{props.selected.length > 5 && (
{deletedFiles.length > 5 && (
<FormattedMessage
values={{
count: props.selected.length - 5,
count: deletedFiles.length - 5,
singularEntity: intl.formatMessage({ id: "file" }),
pluralEntity: intl.formatMessage({ id: "files" }),
}}
Expand Down Expand Up @@ -126,7 +144,9 @@ export const DeleteScenesDialog: React.FC<IDeleteSceneDialogProps> = (
<Form.Check
id="delete-file"
checked={deleteFile}
label={intl.formatMessage({ id: "actions.delete_file" })}
label={intl.formatMessage({
id: "actions.delete_file_and_funscript",
})}
onChange={() => setDeleteFile(!deleteFile)}
/>
<Form.Check
Expand Down
1 change: 1 addition & 0 deletions ui/v2.5/src/locales/en-GB.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"delete": "Delete",
"delete_entity": "Delete {entityType}",
"delete_file": "Delete file",
"delete_file_and_funscript": "Delete file (and funscript)",
"delete_generated_supporting_files": "Delete generated supporting files",
"disallow": "Disallow",
"download": "Download",
Expand Down