-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DB: Fix 0/NULL issues when reading source_synchronized_ms #4012
Conversation
I have added the schema migration. For extra safety the value 0 is no longer valid, because it indicates a bogus value. |
...even though the edge is already handled before and will never occur.
What if I last modified my file on January 1st, 1970?😁 Seriously though, from time to time I've seem those kind of file modification times, probably because some other software was buggy. Would that cause any undesired behavior? |
All files in the nix store are defaulted to that modified time if you don't set it to something specific
It could be that somebody nixifies his music collection ;) |
Just one more reason to ignore this time stamp and treat it as NULL, i.e. unknown. |
If the file modification time doesn't reflect a valid time then it should be ignored. That's what this PR does besides fixing the actual bug. |
It would be dangerous if we add logic on top of useless data. If you don't time stamp your files properly you will simply not be able to use the extended metadata synchronization. That's safe and fair. |
I must admit that I didn't think about the 0 edge case. In the end the occurrence of this bug was actually helpful to discover and resolve it early before it could do any harm 😅 |
@@ -151,8 +151,12 @@ void exportMetadata(djinterop::database* pDatabase, | |||
snapshot.comment = pTrack->getComment().toStdString(); | |||
snapshot.composer = pTrack->getComposer().toStdString(); | |||
snapshot.key = toDjinteropKey(pTrack->getKey()); | |||
int64_t lastModifiedMillisSinceEpoch = | |||
pTrack->getFileInfo().lastModified().toMSecsSinceEpoch(); | |||
int64_t lastModifiedMillisSinceEpoch = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mr-smidge I fixed a possible edge case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thank you 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, Thank you.
Unfortunately I noticed a very strange behavior of Qt when reading a nullable integer database column that contains NULL:
As a consequence the column
library.source_synchronized_ms
now contains 0 (= zero) instead of NULL for some tracks after they have been loaded and saved at least once after the migration.Do we need a formal DB schema update to fix this issue? This would probably be the safe solution.
The first commit is just a minor logging improvement to detect inconsistencies between the library and external files.