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>
This commit is contained in:
kermieisinthehouse
2022-02-02 16:58:48 -08:00
committed by GitHub
parent 0e514183a7
commit 10bb9a6abc
4 changed files with 35 additions and 5 deletions

View File

@@ -135,6 +135,14 @@ func Destroy(scene *models.Scene, repo models.Repository, fileDeleter *FileDelet
if err := fileDeleter.Files([]string{scene.Path}); err != nil { if err := fileDeleter.Files([]string{scene.Path}); err != nil {
return err 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 { if deleteGenerated {

View File

@@ -11,6 +11,7 @@
* Show counts on list tabs in Performer, Studio and Tag pages. ([#2169](https://github.com/stashapp/stash/pull/2169)) * Show counts on list tabs in Performer, Studio and Tag pages. ([#2169](https://github.com/stashapp/stash/pull/2169))
### 🐛 Bug fixes ### 🐛 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)) * 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)) * 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)) * Resolve CDP hostname if necessary. ([#2174](https://github.com/stashapp/stash/pull/2174))

View File

@@ -67,11 +67,29 @@ export const DeleteScenesDialog: React.FC<IDeleteSceneDialogProps> = (
props.onClose(true); 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() { function maybeRenderDeleteFileAlert() {
if (!deleteFile) { if (!deleteFile) {
return; return;
} }
const deletedFiles: string[] = [];
props.selected.forEach((s) => {
deletedFiles.push(s.path);
if (s.interactive) {
deletedFiles.push(funscriptPath(s.path));
}
});
return ( return (
<div className="delete-dialog alert alert-danger text-break"> <div className="delete-dialog alert alert-danger text-break">
<p className="font-weight-bold"> <p className="font-weight-bold">
@@ -85,13 +103,13 @@ export const DeleteScenesDialog: React.FC<IDeleteSceneDialogProps> = (
/> />
</p> </p>
<ul> <ul>
{props.selected.slice(0, 5).map((s) => ( {deletedFiles.slice(0, 5).map((s) => (
<li key={s.path}>{s.path}</li> <li key={s}>{s}</li>
))} ))}
{props.selected.length > 5 && ( {deletedFiles.length > 5 && (
<FormattedMessage <FormattedMessage
values={{ values={{
count: props.selected.length - 5, count: deletedFiles.length - 5,
singularEntity: intl.formatMessage({ id: "file" }), singularEntity: intl.formatMessage({ id: "file" }),
pluralEntity: intl.formatMessage({ id: "files" }), pluralEntity: intl.formatMessage({ id: "files" }),
}} }}
@@ -126,7 +144,9 @@ export const DeleteScenesDialog: React.FC<IDeleteSceneDialogProps> = (
<Form.Check <Form.Check
id="delete-file" id="delete-file"
checked={deleteFile} checked={deleteFile}
label={intl.formatMessage({ id: "actions.delete_file" })} label={intl.formatMessage({
id: "actions.delete_file_and_funscript",
})}
onChange={() => setDeleteFile(!deleteFile)} onChange={() => setDeleteFile(!deleteFile)}
/> />
<Form.Check <Form.Check

View File

@@ -25,6 +25,7 @@
"delete": "Delete", "delete": "Delete",
"delete_entity": "Delete {entityType}", "delete_entity": "Delete {entityType}",
"delete_file": "Delete file", "delete_file": "Delete file",
"delete_file_and_funscript": "Delete file (and funscript)",
"delete_generated_supporting_files": "Delete generated supporting files", "delete_generated_supporting_files": "Delete generated supporting files",
"disallow": "Disallow", "disallow": "Disallow",
"download": "Download", "download": "Download",