diff --git a/src/coreservices.cpp b/src/coreservices.cpp index 3a66ab5decc..e1b57089f90 100644 --- a/src/coreservices.cpp +++ b/src/coreservices.cpp @@ -357,7 +357,7 @@ void CoreServices::initialize(QApplication* pApp) { // the uninitialized singleton instance! m_pPlayerManager->bindToLibrary(m_pLibrary.get()); - bool hasChanged_MusicDir = false; + bool musicDirAdded = false; if (m_pTrackCollectionManager->internalCollection()->loadRootDirs().isEmpty()) { // TODO(XXX) this needs to be smarter, we can't distinguish between an empty @@ -371,10 +371,9 @@ void CoreServices::initialize(QApplication* pApp) { tr("Choose music library directory"), QStandardPaths::writableLocation( QStandardPaths::MusicLocation)); - if (!fd.isEmpty()) { - // adds Folder to database. - m_pLibrary->slotRequestAddDir(fd); - hasChanged_MusicDir = true; + // request to add directory to database. + if (!fd.isEmpty() && m_pLibrary->requestAddDir(fd)) { + musicDirAdded = true; } } @@ -425,7 +424,7 @@ void CoreServices::initialize(QApplication* pApp) { // Scan the library directory. Do this after the skinloader has // loaded a skin, see issue #6625 - if (rescan || hasChanged_MusicDir || m_pSettingsManager->shouldRescanLibrary()) { + if (rescan || musicDirAdded || m_pSettingsManager->shouldRescanLibrary()) { m_pTrackCollectionManager->startLibraryScan(); } diff --git a/src/library/browse/browsefeature.cpp b/src/library/browse/browsefeature.cpp index 180c67008d0..f0ee679d29f 100644 --- a/src/library/browse/browsefeature.cpp +++ b/src/library/browse/browsefeature.cpp @@ -46,10 +46,6 @@ BrowseFeature::BrowseFeature( m_proxyModel(&m_browseModel, true), m_pSidebarModel(new FolderTreeModel(this)), m_pLastRightClickedItem(nullptr) { - connect(this, - &BrowseFeature::requestAddDir, - pLibrary, - &Library::slotRequestAddDir); connect(&m_browseModel, &BrowseTableModel::restoreModelState, this, @@ -178,7 +174,9 @@ void BrowseFeature::slotAddToLibrary() { return; } QString spath = m_pLastRightClickedItem->getData().toString(); - emit requestAddDir(spath); + if (!m_pLibrary->requestAddDir(spath)) { + return; + } QMessageBox msgBox; msgBox.setIcon(QMessageBox::Warning); diff --git a/src/library/dao/directorydao.cpp b/src/library/dao/directorydao.cpp index 6c833efe816..c1022eb47e8 100644 --- a/src/library/dao/directorydao.cpp +++ b/src/library/dao/directorydao.cpp @@ -79,10 +79,17 @@ DirectoryDAO::AddResult DirectoryDAO::addDirectory( if (!newDir.exists() || !newDir.isDir()) { kLogger.warning() << "Failed to add" - << newDir + << newDir.location() << ": Directory does not exist or is inaccessible"; return AddResult::InvalidOrMissingDirectory; } + if (!newDir.isReadable()) { + kLogger.warning() + << "Aborting to to add" + << newDir.location() + << ": Directory can not be read"; + return AddResult::UnreadableDirectory; + } const auto newCanonicalLocation = newDir.canonicalLocation(); DEBUG_ASSERT(!newCanonicalLocation.isEmpty()); QList obsoleteChildDirs; @@ -91,7 +98,7 @@ DirectoryDAO::AddResult DirectoryDAO::addDirectory( // Worst that can happen is that we have orphan tracks in the database that // would be moved to missing after the rescan (which is required anyway after // having added a new dir). - for (auto&& oldDir : loadAllDirectories(true)) { + for (auto&& oldDir : loadAllDirectories(true /* ignore missing */)) { const auto oldCanonicalLocation = oldDir.canonicalLocation(); DEBUG_ASSERT(!oldCanonicalLocation.isEmpty()); if (mixxx::FileInfo::isRootSubCanonicalLocation( @@ -126,7 +133,7 @@ DirectoryDAO::AddResult DirectoryDAO::addDirectory( if (RemoveResult::Ok != removeDirectory(oldDir)) { kLogger.warning() << "Failed to remove obsolete child directory" - << oldDir; + << oldDir.location(); DEBUG_ASSERT(!"removeDirectory failed"); continue; } @@ -161,7 +168,7 @@ DirectoryDAO::RemoveResult DirectoryDAO::removeDirectory( return RemoveResult::Ok; } -QList DirectoryDAO::relocateDirectory( +std::pair> DirectoryDAO::relocateDirectory( const QString& oldDirectory, const QString& newDirectory) const { // Don't verify the old directory with @@ -170,7 +177,28 @@ QList DirectoryDAO::relocateDirectory( // valid location. // Just work with the QString; in case of an invalid path track relocation // will simply fail if the database query yields no results. - DEBUG_ASSERT(newDirectory == mixxx::FileInfo(newDirectory).location()); + const mixxx::FileInfo newFileInfo(newDirectory); + DEBUG_ASSERT(newDirectory == newFileInfo.location()); + + if (!newFileInfo.exists() || !newFileInfo.isDir()) { + kLogger.warning() + << "Aborting to relocate" + << oldDirectory + << ": " + << newDirectory + << "does not exist or is inaccessible"; + return {RelocateResult::InvalidOrMissingDirectory, {}}; + } + if (!newFileInfo.isReadable()) { + kLogger.warning() + << "Aborting to relocate" + << oldDirectory + << ": " + << newDirectory + << "can not be read"; + return {RelocateResult::UnreadableDirectory, {}}; + } + // TODO(rryan): This method could use error reporting. It can fail in // mysterious ways for example if a track in the oldDirectory also has a zombie // track location in newDirectory then the replace query will fail because the @@ -183,7 +211,7 @@ QList DirectoryDAO::relocateDirectory( if (!query.exec()) { LOG_FAILED_QUERY(query) << "could not relocate directory" << oldDirectory << "to" << newDirectory; - return {}; + return {RelocateResult::SqlError, {}}; } // Appending '/' is required to disambiguate files from parent @@ -199,7 +227,7 @@ QList DirectoryDAO::relocateDirectory( query.bindValue(":oldDirectoryPrefix", oldDirectoryPrefix); if (!query.exec()) { LOG_FAILED_QUERY(query) << "could not relocate path of tracks"; - return {}; + return {RelocateResult::SqlError, {}}; } QList loc_ids; @@ -233,10 +261,10 @@ QList DirectoryDAO::relocateDirectory( query.bindValue(QStringLiteral(":id"), loc_ids.at(i).toVariant()); if (!query.exec()) { LOG_FAILED_QUERY(query) << "could not relocate path of track"; - return {}; + return {RelocateResult::SqlError, relocatedTracks}; } } qDebug() << "Relocated tracks:" << relocatedTracks.size(); - return relocatedTracks; + return {RelocateResult::Ok, relocatedTracks}; } diff --git a/src/library/dao/directorydao.h b/src/library/dao/directorydao.h index 715b8a71a58..b59a58b2bd1 100644 --- a/src/library/dao/directorydao.h +++ b/src/library/dao/directorydao.h @@ -20,6 +20,7 @@ class DirectoryDAO : public DAO { Ok, AlreadyWatching, InvalidOrMissingDirectory, + UnreadableDirectory, SqlError, }; AddResult addDirectory(const mixxx::FileInfo& newDir) const; @@ -31,8 +32,14 @@ class DirectoryDAO : public DAO { }; RemoveResult removeDirectory(const mixxx::FileInfo& oldDir) const; + enum class RelocateResult { + Ok, + InvalidOrMissingDirectory, + UnreadableDirectory, + SqlError, + }; // TODO: Move this function out of the DAO - QList relocateDirectory( + std::pair> relocateDirectory( const QString& oldDirectory, const QString& newDirectory) const; }; diff --git a/src/library/library.cpp b/src/library/library.cpp index eaef0121bdd..21f82be564e 100644 --- a/src/library/library.cpp +++ b/src/library/library.cpp @@ -579,7 +579,7 @@ void Library::onSkinLoadFinished() { m_pSidebarModel->activateDefaultSelection(); } -void Library::slotRequestAddDir(const QString& dir) { +bool Library::requestAddDir(const QString& dir) { // We only call this method if the user has picked a new directory via a // file dialog. This means the system sandboxer (if we are sandboxed) has // granted us permission to this folder. Create a security bookmark while we @@ -589,24 +589,59 @@ void Library::slotRequestAddDir(const QString& dir) { QDir directory(dir); Sandbox::createSecurityTokenForDir(directory); - if (!m_pTrackCollectionManager->addDirectory(mixxx::FileInfo(dir))) { - QMessageBox::information(nullptr, - tr("Add Directory to Library"), - tr("Could not add the directory to your library. Either this " - "directory is already in your library or you are currently " - "rescanning your library.")); + DirectoryDAO::AddResult result = + m_pTrackCollectionManager->addDirectory(mixxx::FileInfo(dir)); + QString error; + switch (result) { + case DirectoryDAO::AddResult::Ok: + break; + case DirectoryDAO::AddResult::AlreadyWatching: + error = tr("This or a parent directory is already in your library."); + break; + case DirectoryDAO::AddResult::InvalidOrMissingDirectory: + error = tr( + "This or a listed directory does not exist or is inaccessible.\n" + "Aborting the operation to avoid library inconsistencies"); + break; + case DirectoryDAO::AddResult::UnreadableDirectory: + error = tr( + "This directory can not be read."); + break; + case DirectoryDAO::AddResult::SqlError: + error = tr( + "An unknown error occurred.\n" + "Aborting the operation to avoid library inconsistencies"); + break; + default: + return false; } - // set at least one directory in the config file so that it will be possible - // to downgrade from 1.12 - if (m_pConfig->getValueString(kLegacyDirectoryConfigKey).length() < 1) { - m_pConfig->set(kLegacyDirectoryConfigKey, dir); + if (!error.isEmpty()) { + QMessageBox::information(nullptr, + tr("Can't add Directory to Library"), + tr("Could not add %1 to your library.\n\n%2") + .arg(directory.absolutePath(), error)); + return false; } + + return true; } -void Library::slotRequestRemoveDir(const QString& dir, LibraryRemovalType removalType) { +bool Library::requestRemoveDir(const QString& dir, LibraryRemovalType removalType) { // Remove the directory from the directory list. - if (!m_pTrackCollectionManager->removeDirectory(mixxx::FileInfo(dir))) { - return; + DirectoryDAO::RemoveResult result = + m_pTrackCollectionManager->removeDirectory(mixxx::FileInfo(dir)); + if (result != DirectoryDAO::RemoveResult::Ok) { + switch (result) { + case DirectoryDAO::RemoveResult::NotFound: + case DirectoryDAO::RemoveResult::SqlError: + QMessageBox::information(nullptr, + tr("Can't remove Directory from Library"), + tr("An unknown error occurred.")); + break; + default: + DEBUG_ASSERT(!"unreachable"); + } + return false; } switch (removalType) { @@ -625,32 +660,36 @@ void Library::slotRequestRemoveDir(const QString& dir, LibraryRemovalType remova DEBUG_ASSERT(!"unreachable"); } - // Also update the config file if necessary so that downgrading is still - // possible. - QString confDir = m_pConfig->getValueString(kLegacyDirectoryConfigKey); - - if (QDir(dir) == QDir(confDir)) { - const QList dirList = - m_pTrackCollectionManager->internalCollection()->loadRootDirs(); - if (dirList.isEmpty()) { - // Save empty string so that an old version of mixxx knows it has to - // ask for a new directory. - m_pConfig->set(kLegacyDirectoryConfigKey, QString()); - } else { - m_pConfig->set(kLegacyDirectoryConfigKey, dirList.first().location()); - } - } + return true; } -void Library::slotRequestRelocateDir(const QString& oldDir, const QString& newDir) { - m_pTrackCollectionManager->relocateDirectory(oldDir, newDir); +bool Library::requestRelocateDir(const QString& oldDir, const QString& newDir) { + DirectoryDAO::RelocateResult result = + m_pTrackCollectionManager->relocateDirectory(oldDir, newDir); + if (result == DirectoryDAO::RelocateResult::Ok) { + return true; + } - // also update the config file if necessary so that downgrading is still - // possible - QString conDir = m_pConfig->getValueString(kLegacyDirectoryConfigKey); - if (oldDir == conDir) { - m_pConfig->set(kLegacyDirectoryConfigKey, newDir); + QString error; + switch (result) { + case DirectoryDAO::RelocateResult::InvalidOrMissingDirectory: + error = tr( + "This directory does not exist or is inaccessible."); + break; + case DirectoryDAO::RelocateResult::UnreadableDirectory: + error = tr( + "This directory can not be read."); + break; + default: + DEBUG_ASSERT(!"unreachable"); + } + if (!error.isEmpty()) { + QMessageBox::information(nullptr, + tr("Relink Directory"), + tr("Could not relink %1 to %2.\n\n%3") + .arg(oldDir, newDir, error)); } + return false; } void Library::setFont(const QFont& font) { diff --git a/src/library/library.h b/src/library/library.h index 296812bc3c2..e0190084eeb 100644 --- a/src/library/library.h +++ b/src/library/library.h @@ -102,6 +102,10 @@ class Library: public QObject { /// and shows the results by switching the view. void searchTracksInCollection(const QString& query); + bool requestAddDir(const QString& directory); + bool requestRemoveDir(const QString& directory, LibraryRemovalType removalType); + bool requestRelocateDir(const QString& previousDirectory, const QString& newDirectory); + #ifdef __ENGINEPRIME__ std::unique_ptr makeLibraryExporter(QWidget* parent); #endif @@ -115,9 +119,6 @@ class Library: public QObject { void slotRefreshLibraryModels(); void slotCreatePlaylist(); void slotCreateCrate(); - void slotRequestAddDir(const QString& directory); - void slotRequestRemoveDir(const QString& directory, LibraryRemovalType removalType); - void slotRequestRelocateDir(const QString& previousDirectory, const QString& newDirectory); void onSkinLoadFinished(); void slotSaveCurrentViewState() const; void slotRestoreCurrentViewState() const; diff --git a/src/library/trackcollection.cpp b/src/library/trackcollection.cpp index 3991c6711b1..1c81a16a79c 100644 --- a/src/library/trackcollection.cpp +++ b/src/library/trackcollection.cpp @@ -149,44 +149,48 @@ QStringList TrackCollection::getRootDirStrings() const { return m_directoryDao.getRootDirStrings(); } -bool TrackCollection::addDirectory(const mixxx::FileInfo& rootDir) { +DirectoryDAO::AddResult TrackCollection::addDirectory(const mixxx::FileInfo& rootDir) { DEBUG_ASSERT_QOBJECT_THREAD_AFFINITY(this); SqlTransaction transaction(m_database); - switch (m_directoryDao.addDirectory(rootDir)) { + DirectoryDAO::AddResult result = m_directoryDao.addDirectory(rootDir); + switch (result) { case DirectoryDAO::AddResult::Ok: transaction.commit(); - return true; + break; case DirectoryDAO::AddResult::AlreadyWatching: - return true; case DirectoryDAO::AddResult::InvalidOrMissingDirectory: + case DirectoryDAO::AddResult::UnreadableDirectory: case DirectoryDAO::AddResult::SqlError: - return false; + break; default: DEBUG_ASSERT("unreachable"); + return DirectoryDAO::AddResult::SqlError; } - return false; + return result; } -bool TrackCollection::removeDirectory(const mixxx::FileInfo& rootDir) { +DirectoryDAO::RemoveResult TrackCollection::removeDirectory(const mixxx::FileInfo& rootDir) { DEBUG_ASSERT_QOBJECT_THREAD_AFFINITY(this); SqlTransaction transaction(m_database); - switch (m_directoryDao.removeDirectory(rootDir)) { + DirectoryDAO::RemoveResult result = m_directoryDao.removeDirectory(rootDir); + switch (result) { case DirectoryDAO::RemoveResult::Ok: transaction.commit(); - return true; + break; case DirectoryDAO::RemoveResult::NotFound: - return true; case DirectoryDAO::RemoveResult::SqlError: - return false; + break; default: DEBUG_ASSERT("unreachable"); + return DirectoryDAO::RemoveResult::SqlError; } - return false; + return result; } -void TrackCollection::relocateDirectory(const QString& oldDir, const QString& newDir) { +DirectoryDAO::RelocateResult TrackCollection::relocateDirectory( + const QString& oldDir, const QString& newDir) { DEBUG_ASSERT_QOBJECT_THREAD_AFFINITY(this); // We only call this method if the user has picked a relocated directory via @@ -198,19 +202,22 @@ void TrackCollection::relocateDirectory(const QString& oldDir, const QString& ne Sandbox::createSecurityTokenForDir(QDir(newDir)); SqlTransaction transaction(m_database); - QList relocatedTracks = - m_directoryDao.relocateDirectory(oldDir, newDir); + DirectoryDAO::RelocateResult result; + QList relocatedTracks; + std::tie(result, relocatedTracks) = m_directoryDao.relocateDirectory(oldDir, newDir); transaction.commit(); - if (relocatedTracks.isEmpty()) { - // No tracks moved - return; + if (result != DirectoryDAO::RelocateResult::Ok || relocatedTracks.isEmpty()) { + // Error or no tracks moved + return result; } // Inform the TrackDAO about the changes m_trackDao.slotDatabaseTracksRelocated(std::move(relocatedTracks)); GlobalTrackCacheLocker().relocateCachedTracks(&m_trackDao); + + return result; } QList TrackCollection::resolveTrackIds( diff --git a/src/library/trackcollection.h b/src/library/trackcollection.h index 167f3446c15..1e6ed58de37 100644 --- a/src/library/trackcollection.h +++ b/src/library/trackcollection.h @@ -159,10 +159,9 @@ class TrackCollection : public QObject, bool purgeTracks(const QList& trackIds); bool purgeAllTracks(const QDir& rootDir); - bool addDirectory(const mixxx::FileInfo& rootDir); - bool removeDirectory(const mixxx::FileInfo& rootDir); - - void relocateDirectory(const QString& oldDir, const QString& newDir); + DirectoryDAO::AddResult addDirectory(const mixxx::FileInfo& rootDir); + DirectoryDAO::RemoveResult removeDirectory(const mixxx::FileInfo& rootDir); + DirectoryDAO::RelocateResult relocateDirectory(const QString& oldDir, const QString& newDir); bool saveTrack(Track* pTrack) const; diff --git a/src/library/trackcollectionmanager.cpp b/src/library/trackcollectionmanager.cpp index 1f07ea71263..397b87bac74 100644 --- a/src/library/trackcollectionmanager.cpp +++ b/src/library/trackcollectionmanager.cpp @@ -339,19 +339,21 @@ ExportTrackMetadataResult TrackCollectionManager::exportTrackMetadataBeforeSavin return ExportTrackMetadataResult::Skipped; } -bool TrackCollectionManager::addDirectory(const mixxx::FileInfo& newDir) const { +DirectoryDAO::AddResult TrackCollectionManager::addDirectory(const mixxx::FileInfo& newDir) const { DEBUG_ASSERT_QOBJECT_THREAD_AFFINITY(this); return m_pInternalCollection->addDirectory(newDir); } -bool TrackCollectionManager::removeDirectory(const mixxx::FileInfo& oldDir) const { +DirectoryDAO::RemoveResult TrackCollectionManager::removeDirectory( + const mixxx::FileInfo& oldDir) const { DEBUG_ASSERT_QOBJECT_THREAD_AFFINITY(this); return m_pInternalCollection->removeDirectory(oldDir); } -void TrackCollectionManager::relocateDirectory(const QString& oldDir, const QString& newDir) const { +DirectoryDAO::RelocateResult TrackCollectionManager::relocateDirectory( + const QString& oldDir, const QString& newDir) const { DEBUG_ASSERT_QOBJECT_THREAD_AFFINITY(this); kLogger.debug() @@ -359,21 +361,24 @@ void TrackCollectionManager::relocateDirectory(const QString& oldDir, const QStr << oldDir << "->" << newDir; - // TODO(XXX): Add error handling in TrackCollection::relocateDirectory() - m_pInternalCollection->relocateDirectory(oldDir, newDir); - if (m_externalCollections.isEmpty()) { - return; - } - kLogger.debug() - << "Relocating directory in" - << m_externalCollections.size() - << "external track collection(s):" - << oldDir - << "->" - << newDir; - for (const auto& externalTrackCollection : m_externalCollections) { - externalTrackCollection->relocateDirectory(oldDir, newDir); + DirectoryDAO::RelocateResult result = + m_pInternalCollection->relocateDirectory(oldDir, newDir); + + if (result == DirectoryDAO::RelocateResult::Ok && + !m_externalCollections.isEmpty()) { + kLogger.debug() + << "Relocating directory in" + << m_externalCollections.size() + << "external track collection(s):" + << oldDir + << "->" + << newDir; + // NOTE(ronso0) What are external track collections? + for (const auto& externalTrackCollection : m_externalCollections) { + externalTrackCollection->relocateDirectory(oldDir, newDir); + } } + return result; } bool TrackCollectionManager::hideTracks(const QList& trackIds) const { diff --git a/src/library/trackcollectionmanager.h b/src/library/trackcollectionmanager.h index 7fe8545bcb4..edf48753e05 100644 --- a/src/library/trackcollectionmanager.h +++ b/src/library/trackcollectionmanager.h @@ -5,6 +5,7 @@ #include #include +#include "library/dao/directorydao.h" #include "preferences/usersettings.h" #include "track/globaltrackcache.h" #include "util/db/dbconnectionpool.h" @@ -72,9 +73,10 @@ class TrackCollectionManager: public QObject, void purgeTracks(const QList& trackRefs) const; void purgeAllTracks(const QDir& rootDir) const; - bool addDirectory(const mixxx::FileInfo& newDir) const; - bool removeDirectory(const mixxx::FileInfo& oldDir) const; - void relocateDirectory(const QString& oldDir, const QString& newDir) const; + DirectoryDAO::AddResult addDirectory(const mixxx::FileInfo& newDir) const; + DirectoryDAO::RemoveResult removeDirectory(const mixxx::FileInfo& oldDir) const; + DirectoryDAO::RelocateResult relocateDirectory( + const QString& oldDir, const QString& newDir) const; TrackPointer getOrAddTrack( const TrackRef& trackRef, diff --git a/src/preferences/dialog/dlgpreflibrary.cpp b/src/preferences/dialog/dlgpreflibrary.cpp index 81eaf7243c1..c5151d87a78 100644 --- a/src/preferences/dialog/dlgpreflibrary.cpp +++ b/src/preferences/dialog/dlgpreflibrary.cpp @@ -42,18 +42,6 @@ DlgPrefLibrary::DlgPrefLibrary( QStringLiteral("[Channel1]"), QStringLiteral("rateRange"), this)) { setupUi(this); - connect(this, - &DlgPrefLibrary::requestAddDir, - m_pLibrary.get(), - &Library::slotRequestAddDir); - connect(this, - &DlgPrefLibrary::requestRemoveDir, - m_pLibrary.get(), - &Library::slotRequestRemoveDir); - connect(this, - &DlgPrefLibrary::requestRelocateDir, - m_pLibrary.get(), - &Library::slotRequestRelocateDir); connect(pushButton_add_dir, &QPushButton::clicked, this, @@ -406,9 +394,10 @@ void DlgPrefLibrary::slotAddDir() { this, tr("Choose a music directory"), QStandardPaths::writableLocation(QStandardPaths::MusicLocation)); if (!fd.isEmpty()) { - emit requestAddDir(fd); - slotUpdate(); - m_bAddedDirectory = true; + if (m_pLibrary->requestAddDir(fd)) { + populateDirList(); + m_bAddedDirectory = true; + } } } @@ -464,8 +453,9 @@ void DlgPrefLibrary::slotRemoveDir() { removalType = LibraryRemovalType::KeepTracks; } - emit requestRemoveDir(fd, removalType); - slotUpdate(); + if (m_pLibrary->requestRemoveDir(fd, removalType)) { + populateDirList(); + } } void DlgPrefLibrary::slotRelocateDir() { @@ -486,9 +476,8 @@ void DlgPrefLibrary::slotRelocateDir() { QString fd = QFileDialog::getExistingDirectory( this, tr("Relink music directory to new location"), startDir); - if (!fd.isEmpty()) { - emit requestRelocateDir(currentFd, fd); - slotUpdate(); + if (!fd.isEmpty() && m_pLibrary->requestRelocateDir(currentFd, fd)) { + populateDirList(); } } diff --git a/src/preferences/upgrade.cpp b/src/preferences/upgrade.cpp index f9b33f81a7a..3840374433d 100644 --- a/src/preferences/upgrade.cpp +++ b/src/preferences/upgrade.cpp @@ -471,8 +471,10 @@ UserSettingsPointer Upgrade::versionUpgrade(const QString& settingsPath) { // Sandbox isn't setup yet at this point in startup because it relies on // the config settings path and this function is what loads the config // so it's not ready yet. - successful = tc.addDirectory(mixxx::FileInfo(currentFolder)); - + successful = + tc.addDirectory(mixxx::FileInfo(currentFolder)) == + DirectoryDAO::AddResult::Ok; + ; tc.disconnectDatabase(); } } diff --git a/src/test/directorydaotest.cpp b/src/test/directorydaotest.cpp index 3b88755988a..95f3aa61936 100644 --- a/src/test/directorydaotest.cpp +++ b/src/test/directorydaotest.cpp @@ -283,7 +283,7 @@ TEST_F(DirectoryDAOTest, relocateDirectory) { .isValid()); QList relocatedTracks = - dao.relocateDirectory(oldDirPath, newDirPath); + dao.relocateDirectory(oldDirPath, newDirPath).second; EXPECT_EQ(2, relocatedTracks.size()); const QList newDirs = dao.loadAllDirectories();