-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add relocate button in the missing track library. #16609
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
base: main
Are you sure you want to change the base?
Changes from 5 commits
92f3ab0
e2fe302
d30dd1e
c79a860
c9ac4b2
8cade0f
fb5bc21
0e1fe83
77c0528
1e5aca7
d006eab
76c878b
52c94ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1778,6 +1778,44 @@ bool TrackDAO::updateTrack(const Track& track) const { | |
| return true; | ||
| } | ||
|
|
||
| // Relocate the file linked to the track | ||
| bool TrackDAO::relocateTrack(const Track& track, const mixxx::FileInfo& newLocation) const { | ||
| const TrackId trackId = track.getId(); | ||
| DEBUG_ASSERT(trackId.isValid()); | ||
|
|
||
| kLogger.debug() << "Relocating track" << trackId | ||
| << "from" << track.getLocation() | ||
| << "to" << newLocation; | ||
|
|
||
| SqlTransaction transaction(m_database); | ||
| FwdSqlQuery query(m_database, | ||
| "UPDATE track_locations SET " | ||
| "location = :location," | ||
| "directory = :directory," | ||
| "filename = :filename," | ||
| "filesize = :filesize," | ||
| "fs_deleted = 0," | ||
| "needs_verification = 0 " | ||
| "WHERE id=(SELECT location FROM library WHERE id =:trackId)"); | ||
| query.bindValue(":location", newLocation.location()); | ||
| query.bindValue(":directory", newLocation.locationPath()); | ||
| query.bindValue(":filename", newLocation.fileName()); | ||
| query.bindValue(":filesize", QVariant::fromValue(newLocation.sizeInBytes())); | ||
| query.bindValue(":trackId", trackId.toVariant()); | ||
|
|
||
| if (query.hasError() || !query.execPrepared()) { | ||
| return false; | ||
| } | ||
|
|
||
| if (query.numRowsAffected() == 0) { | ||
| kLogger.warning() << "relocateTrack had no effect: trackId " << trackId << "invalid."; | ||
| return false; | ||
| } | ||
| transaction.commit(); | ||
|
|
||
| return true; | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The similarly named variables in this function make it a bit hard to understand the flow. and also add some comments: Which cases it supposed to cover? (library scan already added a track with new location vs. new location not in db yet)
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The else case covers the case where the new file is outside of the library folder. |
||
|
|
||
| // Make sure that `directory` in in track_locations table is indeed a | ||
| // directory path. This works around / removes residues of a bug where tracks | ||
| // are falsely marked missing because `directory` == `location`. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.