mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 12:24:38 +03:00
File storage rewrite (#2676)
* Restructure data layer part 2 (#2599) * Refactor and separate image model * Refactor image query builder * Handle relationships in image query builder * Remove relationship management methods * Refactor gallery model/query builder * Add scenes to gallery model * Convert scene model * Refactor scene models * Remove unused methods * Add unit tests for gallery * Add image tests * Add scene tests * Convert unnecessary scene value pointers to values * Convert unnecessary pointer values to values * Refactor scene partial * Add scene partial tests * Refactor ImagePartial * Add image partial tests * Refactor gallery partial update * Add partial gallery update tests * Use zero/null package for null values * Add files and scan system * Add sqlite implementation for files/folders * Add unit tests for files/folders * Image refactors * Update image data layer * Refactor gallery model and creation * Refactor scene model * Refactor scenes * Don't set title from filename * Allow galleries to freely add/remove images * Add multiple scene file support to graphql and UI * Add multiple file support for images in graphql/UI * Add multiple file for galleries in graphql/UI * Remove use of some deprecated fields * Remove scene path usage * Remove gallery path usage * Remove path from image * Move funscript to video file * Refactor caption detection * Migrate existing data * Add post commit/rollback hook system * Lint. Comment out import/export tests * Add WithDatabase read only wrapper * Prepend tasks to list * Add 32 pre-migration * Add warnings in release and migration notes
This commit is contained in:
@@ -31,20 +31,11 @@ func TestUpdater_IsEmpty(t *testing.T) {
|
||||
&UpdateSet{},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"id only",
|
||||
&UpdateSet{
|
||||
Partial: models.ScenePartial{
|
||||
ID: 1,
|
||||
},
|
||||
},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"partial set",
|
||||
&UpdateSet{
|
||||
Partial: models.ScenePartial{
|
||||
Organized: &organized,
|
||||
Organized: models.NewOptionalBool(organized),
|
||||
},
|
||||
},
|
||||
false,
|
||||
@@ -52,21 +43,36 @@ func TestUpdater_IsEmpty(t *testing.T) {
|
||||
{
|
||||
"performer set",
|
||||
&UpdateSet{
|
||||
PerformerIDs: ids,
|
||||
Partial: models.ScenePartial{
|
||||
PerformerIDs: &models.UpdateIDs{
|
||||
IDs: ids,
|
||||
Mode: models.RelationshipUpdateModeSet,
|
||||
},
|
||||
},
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"tags set",
|
||||
&UpdateSet{
|
||||
TagIDs: ids,
|
||||
Partial: models.ScenePartial{
|
||||
TagIDs: &models.UpdateIDs{
|
||||
IDs: ids,
|
||||
Mode: models.RelationshipUpdateModeSet,
|
||||
},
|
||||
},
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"performer set",
|
||||
&UpdateSet{
|
||||
StashIDs: stashIDs,
|
||||
Partial: models.ScenePartial{
|
||||
StashIDs: &models.UpdateStashIDs{
|
||||
StashIDs: stashIDs,
|
||||
Mode: models.RelationshipUpdateModeSet,
|
||||
},
|
||||
},
|
||||
},
|
||||
false,
|
||||
},
|
||||
@@ -111,12 +117,6 @@ func TestUpdater_Update(t *testing.T) {
|
||||
tagIDs := []int{tagID}
|
||||
stashID := "stashID"
|
||||
endpoint := "endpoint"
|
||||
stashIDs := []models.StashID{
|
||||
{
|
||||
StashID: stashID,
|
||||
Endpoint: endpoint,
|
||||
},
|
||||
}
|
||||
|
||||
title := "title"
|
||||
cover := []byte("cover")
|
||||
@@ -126,21 +126,12 @@ func TestUpdater_Update(t *testing.T) {
|
||||
updateErr := errors.New("error updating")
|
||||
|
||||
qb := mocks.SceneReaderWriter{}
|
||||
qb.On("Update", ctx, mock.MatchedBy(func(s models.ScenePartial) bool {
|
||||
return s.ID != badUpdateID
|
||||
})).Return(validScene, nil)
|
||||
qb.On("Update", ctx, mock.MatchedBy(func(s models.ScenePartial) bool {
|
||||
return s.ID == badUpdateID
|
||||
})).Return(nil, updateErr)
|
||||
qb.On("UpdatePartial", ctx, mock.MatchedBy(func(id int) bool {
|
||||
return id != badUpdateID
|
||||
}), mock.Anything).Return(validScene, nil)
|
||||
qb.On("UpdatePartial", ctx, badUpdateID, mock.Anything).Return(nil, updateErr)
|
||||
|
||||
qb.On("UpdatePerformers", ctx, sceneID, performerIDs).Return(nil).Once()
|
||||
qb.On("UpdateTags", ctx, sceneID, tagIDs).Return(nil).Once()
|
||||
qb.On("UpdateStashIDs", ctx, sceneID, stashIDs).Return(nil).Once()
|
||||
qb.On("UpdateCover", ctx, sceneID, cover).Return(nil).Once()
|
||||
|
||||
qb.On("UpdatePerformers", ctx, badPerformersID, performerIDs).Return(updateErr).Once()
|
||||
qb.On("UpdateTags", ctx, badTagsID, tagIDs).Return(updateErr).Once()
|
||||
qb.On("UpdateStashIDs", ctx, badStashIDsID, stashIDs).Return(updateErr).Once()
|
||||
qb.On("UpdateCover", ctx, badCoverID, cover).Return(updateErr).Once()
|
||||
|
||||
tests := []struct {
|
||||
@@ -160,13 +151,24 @@ func TestUpdater_Update(t *testing.T) {
|
||||
{
|
||||
"update all",
|
||||
&UpdateSet{
|
||||
ID: sceneID,
|
||||
PerformerIDs: performerIDs,
|
||||
TagIDs: tagIDs,
|
||||
StashIDs: []models.StashID{
|
||||
{
|
||||
StashID: stashID,
|
||||
Endpoint: endpoint,
|
||||
ID: sceneID,
|
||||
Partial: models.ScenePartial{
|
||||
PerformerIDs: &models.UpdateIDs{
|
||||
IDs: performerIDs,
|
||||
Mode: models.RelationshipUpdateModeSet,
|
||||
},
|
||||
TagIDs: &models.UpdateIDs{
|
||||
IDs: tagIDs,
|
||||
Mode: models.RelationshipUpdateModeSet,
|
||||
},
|
||||
StashIDs: &models.UpdateStashIDs{
|
||||
StashIDs: []models.StashID{
|
||||
{
|
||||
StashID: stashID,
|
||||
Endpoint: endpoint,
|
||||
},
|
||||
},
|
||||
Mode: models.RelationshipUpdateModeSet,
|
||||
},
|
||||
},
|
||||
CoverImage: cover,
|
||||
@@ -179,7 +181,7 @@ func TestUpdater_Update(t *testing.T) {
|
||||
&UpdateSet{
|
||||
ID: sceneID,
|
||||
Partial: models.ScenePartial{
|
||||
Title: models.NullStringPtr(title),
|
||||
Title: models.NewOptionalString(title),
|
||||
},
|
||||
},
|
||||
false,
|
||||
@@ -190,39 +192,12 @@ func TestUpdater_Update(t *testing.T) {
|
||||
&UpdateSet{
|
||||
ID: badUpdateID,
|
||||
Partial: models.ScenePartial{
|
||||
Title: models.NullStringPtr(title),
|
||||
Title: models.NewOptionalString(title),
|
||||
},
|
||||
},
|
||||
true,
|
||||
true,
|
||||
},
|
||||
{
|
||||
"error updating performers",
|
||||
&UpdateSet{
|
||||
ID: badPerformersID,
|
||||
PerformerIDs: performerIDs,
|
||||
},
|
||||
true,
|
||||
true,
|
||||
},
|
||||
{
|
||||
"error updating tags",
|
||||
&UpdateSet{
|
||||
ID: badTagsID,
|
||||
TagIDs: tagIDs,
|
||||
},
|
||||
true,
|
||||
true,
|
||||
},
|
||||
{
|
||||
"error updating stash IDs",
|
||||
&UpdateSet{
|
||||
ID: badStashIDsID,
|
||||
StashIDs: stashIDs,
|
||||
},
|
||||
true,
|
||||
true,
|
||||
},
|
||||
{
|
||||
"error updating cover",
|
||||
&UpdateSet{
|
||||
@@ -275,7 +250,7 @@ func TestUpdateSet_UpdateInput(t *testing.T) {
|
||||
Endpoint: endpoint,
|
||||
},
|
||||
}
|
||||
stashIDInputs := []*models.StashIDInput{
|
||||
stashIDInputs := []models.StashID{
|
||||
{
|
||||
StashID: stashID,
|
||||
Endpoint: endpoint,
|
||||
@@ -303,11 +278,22 @@ func TestUpdateSet_UpdateInput(t *testing.T) {
|
||||
{
|
||||
"update all",
|
||||
UpdateSet{
|
||||
ID: sceneID,
|
||||
PerformerIDs: performerIDs,
|
||||
TagIDs: tagIDs,
|
||||
StashIDs: stashIDs,
|
||||
CoverImage: cover,
|
||||
ID: sceneID,
|
||||
Partial: models.ScenePartial{
|
||||
PerformerIDs: &models.UpdateIDs{
|
||||
IDs: performerIDs,
|
||||
Mode: models.RelationshipUpdateModeSet,
|
||||
},
|
||||
TagIDs: &models.UpdateIDs{
|
||||
IDs: tagIDs,
|
||||
Mode: models.RelationshipUpdateModeSet,
|
||||
},
|
||||
StashIDs: &models.UpdateStashIDs{
|
||||
StashIDs: stashIDs,
|
||||
Mode: models.RelationshipUpdateModeSet,
|
||||
},
|
||||
},
|
||||
CoverImage: cover,
|
||||
},
|
||||
models.SceneUpdateInput{
|
||||
ID: sceneIDStr,
|
||||
@@ -322,7 +308,7 @@ func TestUpdateSet_UpdateInput(t *testing.T) {
|
||||
UpdateSet{
|
||||
ID: sceneID,
|
||||
Partial: models.ScenePartial{
|
||||
Title: models.NullStringPtr(title),
|
||||
Title: models.NewOptionalString(title),
|
||||
},
|
||||
},
|
||||
models.SceneUpdateInput{
|
||||
|
||||
Reference in New Issue
Block a user