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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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 {
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 {

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))
### 🐛 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))

View file

@ -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">
@ -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" }),
}}
@ -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

View file

@ -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",