mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 12:54:38 +03:00
Fix image memory issue (#935)
* Return slim images from mutations * Fix potential memory leaks
This commit is contained in:
@@ -16,7 +16,7 @@ mutation ImageUpdate(
|
|||||||
performer_ids: $performer_ids,
|
performer_ids: $performer_ids,
|
||||||
tag_ids: $tag_ids
|
tag_ids: $tag_ids
|
||||||
}) {
|
}) {
|
||||||
...ImageData
|
...SlimImageData
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,13 +38,13 @@ mutation BulkImageUpdate(
|
|||||||
performer_ids: $performer_ids,
|
performer_ids: $performer_ids,
|
||||||
tag_ids: $tag_ids
|
tag_ids: $tag_ids
|
||||||
}) {
|
}) {
|
||||||
...ImageData
|
...SlimImageData
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mutation ImagesUpdate($input : [ImageUpdateInput!]!) {
|
mutation ImagesUpdate($input : [ImageUpdateInput!]!) {
|
||||||
imagesUpdate(input: $input) {
|
imagesUpdate(input: $input) {
|
||||||
...ImageData
|
...SlimImageData
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,11 +90,15 @@ func openSourceImage(path string) (io.ReadCloser, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// defer closing of zip to the calling function, unless an error
|
||||||
|
// is returned, in which case it should be closed immediately
|
||||||
|
|
||||||
// find the file matching the filename
|
// find the file matching the filename
|
||||||
for _, f := range r.File {
|
for _, f := range r.File {
|
||||||
if f.Name == filename {
|
if f.Name == filename {
|
||||||
src, err := f.Open()
|
src, err := f.Open()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
r.Close()
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &imageReadCloser{
|
return &imageReadCloser{
|
||||||
@@ -104,6 +108,7 @@ func openSourceImage(path string) (io.ReadCloser, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
r.Close()
|
||||||
return nil, fmt.Errorf("file with name '%s' not found in zip file '%s'", filename, zipFilename)
|
return nil, fmt.Errorf("file with name '%s' not found in zip file '%s'", filename, zipFilename)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ func walkGalleryZip(path string, walkFunc func(file *zip.File) error) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
defer readCloser.Close()
|
||||||
|
|
||||||
for _, file := range readCloser.File {
|
for _, file := range readCloser.File {
|
||||||
if file.FileInfo().IsDir() {
|
if file.FileInfo().IsDir() {
|
||||||
|
|||||||
Reference in New Issue
Block a user