Fix deleting folder-based gallery file deleting (#1872)

* Fix deleting gallery image files
* Clarify delete file documentation
This commit is contained in:
WithoutPants 2021-10-25 09:29:03 +11:00 committed by GitHub
parent 0ab8d32687
commit d292ed0b34
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 6 deletions

View file

@ -74,6 +74,11 @@ input BulkGalleryUpdateInput {
input GalleryDestroyInput { input GalleryDestroyInput {
ids: [ID!]! ids: [ID!]!
"""
If true, then the zip file will be deleted if the gallery is zip-file-based.
If gallery is folder-based, then any files not associated with other
galleries will be deleted, along with the folder, if it is not empty.
"""
delete_file: Boolean delete_file: Boolean
delete_generated: Boolean delete_generated: Boolean
} }

View file

@ -441,7 +441,7 @@ func (r *mutationResolver) GalleryDestroy(ctx context.Context, input models.Gall
return err return err
} }
if len(imgGalleries) == 0 { if len(imgGalleries) == 1 {
if err := iqb.Destroy(img.ID); err != nil { if err := iqb.Destroy(img.ID); err != nil {
return err return err
} }
@ -465,13 +465,15 @@ func (r *mutationResolver) GalleryDestroy(ctx context.Context, input models.Gall
// if delete file is true, then delete the file as well // if delete file is true, then delete the file as well
// if it fails, just log a message // if it fails, just log a message
if input.DeleteFile != nil && *input.DeleteFile { if input.DeleteFile != nil && *input.DeleteFile {
for _, gallery := range galleries { // #1804 - delete the image files first, since they must be removed
manager.DeleteGalleryFile(gallery) // before deleting a folder
}
for _, img := range imgsToDelete { for _, img := range imgsToDelete {
manager.DeleteImageFile(img) manager.DeleteImageFile(img)
} }
for _, gallery := range galleries {
manager.DeleteGalleryFile(gallery)
}
} }
// if delete generated is true, then delete the generated files // if delete generated is true, then delete the generated files

View file

@ -11,6 +11,7 @@
* Optimised scanning process. ([#1816](https://github.com/stashapp/stash/pull/1816)) * Optimised scanning process. ([#1816](https://github.com/stashapp/stash/pull/1816))
### 🐛 Bug fixes ### 🐛 Bug fixes
* Fix image files in folder galleries not being deleting when delete file option is checked. ([#1872](https://github.com/stashapp/stash/pull/1872))
* Fix marker generation task reading video files unnecessarily. ([#1871](https://github.com/stashapp/stash/pull/1871)) * Fix marker generation task reading video files unnecessarily. ([#1871](https://github.com/stashapp/stash/pull/1871))
* Fix accessing Stash via IPv6 link local address causing security tripwire to be activated. ([#1841](https://github.com/stashapp/stash/pull/1841)) * Fix accessing Stash via IPv6 link local address causing security tripwire to be activated. ([#1841](https://github.com/stashapp/stash/pull/1841))
* Fix Twitter value defaulting to freeones in built-in Freeones scraper. ([#1853](https://github.com/stashapp/stash/pull/1853)) * Fix Twitter value defaulting to freeones in built-in Freeones scraper. ([#1853](https://github.com/stashapp/stash/pull/1853))

View file

@ -82,7 +82,9 @@ export const DeleteGalleriesDialog: React.FC<IDeleteGalleryDialogProps> = (
<Form.Check <Form.Check
id="delete-file" id="delete-file"
checked={deleteFile} checked={deleteFile}
label="Delete zip file and any images not attached to any other gallery." label={intl.formatMessage({
id: "actions.delete_gallery_files",
})}
onChange={() => setDeleteFile(!deleteFile)} onChange={() => setDeleteFile(!deleteFile)}
/> />
<Form.Check <Form.Check

View file

@ -21,6 +21,7 @@
"create_marker": "Create Marker", "create_marker": "Create Marker",
"created_entity": "Created {entity_type}: {entity_name}", "created_entity": "Created {entity_type}: {entity_name}",
"delete": "Delete", "delete": "Delete",
"delete_gallery_files": "Delete gallery folder/zip file and any images not attached to any other gallery.",
"delete_entity": "Delete {entityType}", "delete_entity": "Delete {entityType}",
"delete_file": "Delete file", "delete_file": "Delete file",
"delete_generated_supporting_files": "Delete generated supporting files", "delete_generated_supporting_files": "Delete generated supporting files",