gui: fix media eject on linux (#4700) (#4701)

* gui: fix media eject on linux (#4700)

Removable media is not ejected on linux platform

Make get_removable_drive_from_path() check if path is a dir or not.
Trim last component in latter case only.

* Revert unnecessary style changes
This commit is contained in:
Dima Buzdyk 2024-03-29 08:12:37 +05:00 committed by GitHub
parent a980bb6a6a
commit 45ef4ae790
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -370,12 +370,13 @@ std::string RemovableDriveManager::get_removable_drive_path(const std::string &p
std::string RemovableDriveManager::get_removable_drive_from_path(const std::string& path) std::string RemovableDriveManager::get_removable_drive_from_path(const std::string& path)
{ {
std::size_t found = path.find_last_of("/"); std::string new_path(path);
std::string new_path = found == path.size() - 1 ? path.substr(0, found) : path; if (!boost::filesystem::is_directory(path)) {
// trim the filename std::size_t found = path.find_last_of("/");
found = new_path.find_last_of("/"); if (found != std::string::npos)
new_path = new_path.substr(0, found); new_path.erase(found);
}
// check if same filesystem // check if same filesystem
std::scoped_lock<std::mutex> lock(m_drives_mutex); std::scoped_lock<std::mutex> lock(m_drives_mutex);
for (const DriveData &drive_data : m_current_drives) for (const DriveData &drive_data : m_current_drives)