Scenes with a marker missing a primary tag fails to load

Fixes #42
This commit is contained in:
Stash Dev 2019-04-20 10:32:01 -07:00
parent 7742024dfb
commit d6eb2c2d8e
10 changed files with 30 additions and 35 deletions

View File

@ -46,6 +46,10 @@ Once you have a certificate and key file name them `stash.crt` and `stash.key` a
# FAQ
> I'm unable to run the app on OSX or Linux
Try running `chmod u+x stash-osx` or `chmod u+x stash-linux` to make the file executable.
> I have a question not answered here.
Join the [Discord server](https://discord.gg/2TsNFKt).

File diff suppressed because one or more lines are too long

View File

@ -117,10 +117,7 @@ func (r *queryResolver) SceneMarkerTags(ctx context.Context, scene_id string) ([
var keys []int
tqb := models.NewTagQueryBuilder()
for _, sceneMarker := range sceneMarkers {
if !sceneMarker.PrimaryTagID.Valid {
panic("missing primary tag id")
}
markerPrimaryTag, err := tqb.Find(int(sceneMarker.PrimaryTagID.Int64), nil)
markerPrimaryTag, err := tqb.Find(sceneMarker.PrimaryTagID, nil)
if err != nil {
return nil, err
}

View File

@ -18,10 +18,7 @@ func (r *sceneMarkerResolver) Scene(ctx context.Context, obj *models.SceneMarker
func (r *sceneMarkerResolver) PrimaryTag(ctx context.Context, obj *models.SceneMarker) (*models.Tag, error) {
qb := models.NewTagQueryBuilder()
if !obj.PrimaryTagID.Valid {
panic("TODO no primary tag id")
}
tag, err := qb.Find(int(obj.PrimaryTagID.Int64), nil) // TODO make primary tag id not null in DB
tag, err := qb.Find(obj.PrimaryTagID, nil)
return tag, err
}

View File

@ -108,7 +108,7 @@ func (r *mutationResolver) SceneMarkerCreate(ctx context.Context, input models.S
newSceneMarker := models.SceneMarker{
Title: input.Title,
Seconds: input.Seconds,
PrimaryTagID: sql.NullInt64{Int64: int64(primaryTagID), Valid: primaryTagID != 0},
PrimaryTagID: primaryTagID,
SceneID: sql.NullInt64{Int64: int64(sceneID), Valid: sceneID != 0},
CreatedAt: models.SQLiteTimestamp{Timestamp: currentTime},
UpdatedAt: models.SQLiteTimestamp{Timestamp: currentTime},
@ -127,7 +127,7 @@ func (r *mutationResolver) SceneMarkerUpdate(ctx context.Context, input models.S
Title: input.Title,
Seconds: input.Seconds,
SceneID: sql.NullInt64{Int64: int64(sceneID), Valid: sceneID != 0},
PrimaryTagID: sql.NullInt64{Int64: int64(primaryTagID), Valid: primaryTagID != 0},
PrimaryTagID: primaryTagID,
UpdatedAt: models.SQLiteTimestamp{Timestamp: time.Now()},
}
@ -170,7 +170,7 @@ func changeMarker(ctx context.Context, changeType int, changedMarker models.Scen
var markerTagJoins []models.SceneMarkersTags
for _, tid := range tagIds {
tagID, _ := strconv.Atoi(tid)
if int64(tagID) == changedMarker.PrimaryTagID.Int64 {
if tagID == changedMarker.PrimaryTagID {
continue // If this tag is the primary tag, then let's not add it.
}
markerTag := models.SceneMarkersTags{

View File

@ -70,7 +70,7 @@ CREATE TABLE `scene_markers` (
`id` integer not null primary key autoincrement,
`title` varchar(255) not null,
`seconds` float not null,
`primary_tag_id` integer,
`primary_tag_id` integer not null,
`scene_id` integer,
`created_at` datetime not null,
`updated_at` datetime not null,

View File

@ -109,11 +109,7 @@ func (t *ExportTask) ExportScenes(ctx context.Context) {
newSceneJSON.Tags = t.getTagNames(tags)
for _, sceneMarker := range sceneMarkers {
var primaryTagID int
if sceneMarker.PrimaryTagID.Valid {
primaryTagID = int(sceneMarker.PrimaryTagID.Int64)
}
primaryTag, err := tagQB.Find(primaryTagID, tx)
primaryTag, err := tagQB.Find(sceneMarker.PrimaryTagID, tx)
if err != nil {
logger.Errorf("[scenes] <%s> invalid primary tag for scene marker: %s", scene.Checksum, err.Error())
continue

View File

@ -519,7 +519,7 @@ func (t *ImportTask) ImportScenes(ctx context.Context) {
if err != nil {
logger.Errorf("[scenes] <%s> failed to find primary tag for marker: %s", scene.Checksum, err.Error())
} else {
newSceneMarker.PrimaryTagID = sql.NullInt64{Int64: int64(primaryTag.ID), Valid: true}
newSceneMarker.PrimaryTagID = primaryTag.ID
}
// Create the scene marker in the DB

View File

@ -8,7 +8,7 @@ type SceneMarker struct {
ID int `db:"id" json:"id"`
Title string `db:"title" json:"title"`
Seconds float64 `db:"seconds" json:"seconds"`
PrimaryTagID sql.NullInt64 `db:"primary_tag_id,omitempty" json:"primary_tag_id"`
PrimaryTagID int `db:"primary_tag_id" json:"primary_tag_id"`
SceneID sql.NullInt64 `db:"scene_id,omitempty" json:"scene_id"`
CreatedAt SQLiteTimestamp `db:"created_at" json:"created_at"`
UpdatedAt SQLiteTimestamp `db:"updated_at" json:"updated_at"`

View File

@ -18,6 +18,7 @@ import { FilterSelect } from "../../select/FilterSelect";
import { MarkerTitleSuggest } from "../../select/MarkerTitleSuggest";
import { WallPanel } from "../../Wall/WallPanel";
import { SceneHelpers } from "../helpers";
import { ErrorUtils } from "../../../utils/errors";
interface ISceneMarkersPanelProps {
scene: GQL.SceneDataFragment;
@ -113,17 +114,17 @@ export const SceneMarkersPanel: FunctionComponent<ISceneMarkersPanelProps> = (pr
};
if (!isEditing) {
sceneMarkerCreate({ variables }).then((response) => {
console.log(response);
}).catch((err) => console.error(err));
setIsEditorOpen(false);
setEditingMarker(null);
}).catch((err) => ErrorUtils.handleApolloError(err));
} else {
const updateVariables = variables as GQL.SceneMarkerUpdateVariables;
updateVariables.id = editingMarker!.id;
sceneMarkerUpdate({ variables: updateVariables }).then((response) => {
console.log(response);
}).catch((err) => console.error(err));
setIsEditorOpen(false);
setEditingMarker(null);
}).catch((err) => ErrorUtils.handleApolloError(err));
}
setIsEditorOpen(false);
setEditingMarker(null);
}
function onDelete() {
if (!editingMarker) { return; }