mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
Fix handling of files to delete during delete Gallery operation (#5213)
* Only remove file in zip from image if deleting from zip file * Only remove file in folder from image if deleting from folder
This commit is contained in:
@@ -997,6 +997,21 @@ func (qb *ImageStore) AddFileID(ctx context.Context, id int, fileID models.FileI
|
||||
return imagesFilesTableMgr.insertJoins(ctx, id, firstPrimary, []models.FileID{fileID})
|
||||
}
|
||||
|
||||
// RemoveFileID removes the file ID from the image.
|
||||
// If the file ID is the primary file, then the next file in the list is set as the primary file.
|
||||
func (qb *ImageStore) RemoveFileID(ctx context.Context, id int, fileID models.FileID) error {
|
||||
fileIDs, err := imagesFilesTableMgr.get(ctx, id)
|
||||
if err != nil {
|
||||
return fmt.Errorf("getting file IDs for image %d: %w", id, err)
|
||||
}
|
||||
|
||||
fileIDs = sliceutil.Filter(fileIDs, func(f models.FileID) bool {
|
||||
return f != fileID
|
||||
})
|
||||
|
||||
return imagesFilesTableMgr.replaceJoins(ctx, id, fileIDs)
|
||||
}
|
||||
|
||||
func (qb *ImageStore) GetGalleryIDs(ctx context.Context, imageID int) ([]int, error) {
|
||||
return imageRepository.galleries.getIDs(ctx, imageID)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user