Skip to content
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

library/serato/seratofeature: Fix relative paths on OSX (and on Linux) #2659

Merged
merged 2 commits into from
Apr 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/library/serato/seratofeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,10 +450,25 @@ QString parseDatabase(mixxx::DbConnectionPoolPtr dbConnectionPool, TreeItem* dat
databaseRootDir.cdUp();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is unnecessary now, right?

Copy link
Member Author

@Holzhaus Holzhaus Apr 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. QDir:root() is a static method and always returns the system drive letter. I think you can move your home directory onto a different drive on Windows, right?


#if defined(__WINDOWS__)
// Find drive letter (paths are relative to drive root on Windows)
// On Windows, all paths are relative to drive root of the database (e.g.
// "C:\"). Qt doesn't seem to provide a way to find it for a specific path,
// so we just call cdUp() until it stops working.
while (databaseRootDir.cdUp()) {
// Nothing to do here
}
#else
// If the file is on an external drive, the database path are relative to
// its mountpoint, i.e. the parent directory of the _Serato_
// directory. This means we can just use the path as-is.
//
// If the file is not on an external drive, the paths are all relative to
// the file system's root directory ("/").
//
// Serato does not exist on Linux, if it did, it would probably just mirror
// the way paths are handled on OSX.
if (databaseRootDir.canonicalPath().startsWith(QDir::homePath())) {
databaseRootDir = QDir::root();
}
#endif

qDebug() << "Parsing Serato database"
Expand Down