Skip to content

Commit

Permalink
gui: fix media eject on linux (#4700) (#4701)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
buzzhuzz authored Mar 29, 2024
1 parent a980bb6 commit 45ef4ae
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/slic3r/GUI/RemovableDriveManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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::size_t found = path.find_last_of("/");
std::string new_path = found == path.size() - 1 ? path.substr(0, found) : path;
// trim the filename
found = new_path.find_last_of("/");
new_path = new_path.substr(0, found);

std::string new_path(path);
if (!boost::filesystem::is_directory(path)) {
std::size_t found = path.find_last_of("/");
if (found != std::string::npos)
new_path.erase(found);
}

// check if same filesystem
std::scoped_lock<std::mutex> lock(m_drives_mutex);
for (const DriveData &drive_data : m_current_drives)
Expand Down

0 comments on commit 45ef4ae

Please sign in to comment.