Skip to content

fix(author): ApplyChanges wipes stored paths when an update omits them - #97

Open
Ch3fUlrich wants to merge 1 commit into
Chaptarr:developfrom
Ch3fUlrich:fix/author-put-clears-paths
Open

fix(author): ApplyChanges wipes stored paths when an update omits them#97
Ch3fUlrich wants to merge 1 commit into
Chaptarr:developfrom
Ch3fUlrich:fix/author-put-clears-paths

Conversation

@Ch3fUlrich

Copy link
Copy Markdown

Fixes #88.

What changed and why

Author.ApplyChanges assigned Path, AudiobookRootFolderPath and EbookRootFolderPath unconditionally, so any caller passing an Author without them cleared the stored values.

That is inconsistent with the fields immediately around them, which are all guarded — the quality profiles, the metadata profiles and the tags each check before assigning. The existing comment there already explains why: "Quality profiles from metadata sources are always null/0".

Paths reach the same method from the same two directions:

  • the API, where a PUT /api/v1/author/{id} may legitimately omit fields it is not changing, and
  • metadata refresh, where the incoming Author is built from remote metadata and carries no local paths at all.

Both wiped the stored path. This guards the three assignments the same way the neighbouring fields are guarded.

UseDbFieldsFrom is deliberately left alone — it is a full copy from the database, so assigning unconditionally is correct there.

Breaking changes

None. The only behaviour change is that an omitted (null) path no longer clears the stored one; supplying a path still overwrites it exactly as before.

Testing performed

AuthorApplyChangesPathPreservationFixture covers three cases: preservation when paths are omitted, normal overwrite when they are supplied, and independent preservation when only one of the three changes.

Verified red/green — 2 of the 3 tests fail without the production change:

without the fix:  Failed: 2, Passed: 1, Total: 3
with the fix:     Failed: 0, Passed: 3, Total: 3

Full suite, no regressions:

before:  Passed! - Failed: 0, Passed: 2852, Total: 2852
after:   Passed! - Failed: 0, Passed: 2855, Total: 2855   (+3 new)

Built and tested on .NET SDK 10.0.400, rebased on develop.

…its them

Author.ApplyChanges assigned Path, AudiobookRootFolderPath and EbookRootFolderPath
unconditionally, so any caller passing an Author without them cleared the stored
values. That is inconsistent with the fields immediately around them, which are all
guarded -- the quality profiles, the metadata profiles and the tags each check before
assigning, with the existing comment noting that "Quality profiles from metadata
sources are always null/0".

Paths reach the same method from the same two directions:

  * the API, where a PUT may legitimately omit fields it is not changing, and
  * metadata refresh, where the incoming Author is built from remote metadata and
    carries no local paths at all.

Both wiped the stored path. Guarding the three assignments the same way the
neighbouring fields are guarded fixes it.

UseDbFieldsFrom is deliberately left alone: it is a full copy from the database, so
assigning unconditionally there is correct.

Tests: AuthorApplyChangesPathPreservationFixture covers preservation when the paths
are omitted, normal overwrite when they are supplied, and independent preservation
when only one of the three changes. Verified red/green -- 2 of the 3 fail without the
production change. Full suite 2855 passed / 0 failed (2852 before, +3 new).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant