Fix: Recent Activity rows intermittently dropping AM/PM#181
Merged
Brandon-Haney merged 1 commit intoJun 5, 2026
Merged
Conversation
A row in the Recent Activity feed could render without its AM/PM suffix while its siblings kept theirs. FileActivity.to_dict() called get_time_format() — which re-reads plexcache_settings.json — once per row, and the web settings writer truncated the file in place before rewriting it. When a settings write overlapped a render, one row's read could land in the empty-file window, raise JSONDecodeError, and fall back to the 24h default; at the noon hour that looks identical apart from the missing PM. - to_dict() now accepts an explicit time_format; recent_activity reads it once and passes it to every row so a render is internally consistent. - _save_raw() writes the settings file atomically via save_json_atomically() (write-temp-then-replace) so concurrent readers never see a partial file. - save_json_atomically() returns a bool so the writer keeps its success contract.
StudioNirin
approved these changes
Jun 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A single row in the dashboard's Recent Activity feed could render its time without the AM/PM suffix while the other rows in the same run kept theirs — e.g.
12:32:53next to12:32:56 PM.Root cause
FileActivity.to_dict()calledget_time_format()— which re-readsplexcache_settings.jsonfrom disk — once per row. The web settings writer rewrote that file non-atomically (open(..., 'w')truncates it to zero bytes before writing). When a settings write overlapped a dashboard render, one row's read could land in the truncated-file window, raiseJSONDecodeError, and fall back to the24hdefault. At the noon hour the 24h string (12:32:53) is identical to the 12h one apart from the missingPM, so it looked like one row had simply lost its suffix.Fix
FileActivity.to_dict()accepts an explicittime_format; the activity render path reads the format once and passes it to every row, so a render is always internally consistent (all rows share one format).os.replace) via the sharedsave_json_atomically()helper, so concurrent readers never observe a partial/empty settings file. This protects every settings reader, not just the activity feed.save_json_atomically()returns a bool so the settings writer keeps its success/failure contract.Testing
to_dict()honoring an explicittime_format(and not re-reading settings), andsave_json_atomically()reporting success/failure.Manual verification