mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
Add filesystem based blob storage (#3187)
* Refactor transaction hooks. Add preCommit * Add BlobStore * Use blobStore for tag images * Use blobStore for studio images * Use blobStore for performer images * Use blobStore for scene covers * Don't generate screenshots in legacy directory * Run post-hooks outside original transaction * Use blobStore for movie images * Remove unnecessary DestroyImage methods * Add missing filter for scene cover * Add covers to generate options * Add generate cover option to UI * Add screenshot migration * Delete thumb files as part of screenshot migration
This commit is contained in:
45
pkg/sqlite/blob_test.go
Normal file
45
pkg/sqlite/blob_test.go
Normal file
@@ -0,0 +1,45 @@
|
||||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
package sqlite_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
type updateImageFunc func(ctx context.Context, id int, image []byte) error
|
||||
type getImageFunc func(ctx context.Context, movieID int) ([]byte, error)
|
||||
|
||||
func testUpdateImage(t *testing.T, ctx context.Context, id int, updateFn updateImageFunc, getFn getImageFunc) error {
|
||||
image := []byte("image")
|
||||
err := updateFn(ctx, id, image)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error updating performer image: %s", err.Error())
|
||||
}
|
||||
|
||||
// ensure image set
|
||||
storedImage, err := getFn(ctx, id)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error getting image: %s", err.Error())
|
||||
}
|
||||
assert.Equal(t, storedImage, image)
|
||||
|
||||
// set nil image
|
||||
err = updateFn(ctx, id, nil)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error setting nil image: %w", err)
|
||||
}
|
||||
|
||||
// ensure image null
|
||||
storedImage, err = getFn(ctx, id)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error getting image: %s", err.Error())
|
||||
}
|
||||
assert.Nil(t, storedImage)
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user