Repository navigation
Fix "year must be in 1..9999, not 0" error during update check - #820
harshdeepsinghin wants to merge 2 commits into
Conversation
automaticUpdateCheck() parsed the stored lastCheckedForUpdates value with the format 'yyyy-MM-dd HH-mm-ss', but that value is written with "yyyy-MM-d HH:mm:ss.z" (see GuiConfiguration.loadLastUpdateCheckDate), i.e. with colons in the time and a fractional part. QDateTime.fromString() therefore returned an invalid QDateTime, and calling toPython() on an invalid QDateTime raises "year must be in 1..9999, not 0" with current PySide6. The exception was swallowed by the surrounding try/except, which logged "Automatic check for updates failed..." and forced a manual update check on every launch. Parse the value with the same format it is written with, ignore a value that fails to parse, and treat an invalid date as never checked.
|
Cheers for your work on this. The mismatch between the saved date format and the format used by One small improvement before merging: Could you remove the separate It would be useful to confirm that a recent saved timestamp prevents another automatic update check after restarting Syncplay, while an old, missing or invalid timestamp is handled correctly. Otherwise, this looks like a good, focused fix. |
Remove redundant datetime.strptime() call and compare QDateTime objects directly after validating both dates. This avoids parsing the same configuration value twice, as suggested in PR review.
automaticUpdateCheck()reads the storedlastCheckedForUpdatesvalue with the wrong format:The value is written by
GuiConfiguration.loadLastUpdateCheckDate()with"yyyy-MM-d HH:mm:ss.z"— the time uses colons and there is a fractional part — soQDateTime.fromString()always returns an invalidQDateTime.With current PySide6, calling
toPython()on an invalidQDateTimeraises:The surrounding
try/exceptswallows this and logs"Automatic check for updates failed. An update check was manually trigggered...", then forces a manual update check on every launch.Reproduced with a config value of
2026-10-11 23:09:28.838:QDateTime.fromString(value, 'yyyy-MM-dd HH-mm-ss')→ invalid,toPython()raisesValueErrorQDateTime.fromString(value, 'yyyy-MM-d HH:mm:ss.z')→ validThe fix parses with the same format the value is written with, ignores a value that fails to parse, and treats an invalid date as never checked, so
toPython()is never called on an invalidQDateTime.