Skip to content
This repository has been archived by the owner on Dec 4, 2020. It is now read-only.

Commit

Permalink
Add the ability for the mount tray to "force" an unmount (given a war…
Browse files Browse the repository at this point in the history
…ning ahead of time)
  • Loading branch information
Ken Moore committed Aug 26, 2013
1 parent 408039b commit 22f21be
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src-qt4/pc-mounttray/menuItem.cpp
Expand Up @@ -253,7 +253,7 @@ void MenuItem::mountItem(){

}

void MenuItem::unmountItem(){
void MenuItem::unmountItem(bool force){
//Unmount the device

//Check to see if the current mountpoint exists or if it is somewhere else
Expand All @@ -265,6 +265,7 @@ void MenuItem::unmountItem(){
}
//Make sure there are no spaces in the mounpoint path
QString cmd1 = "umount \"" + mountpoint +"\"";
if(force){ cmd1.replace("umount ","umount -f "); }
QString cmd2 = "rmdir \"" + mountpoint +"\"";
qDebug() << "Unmounting device from" << mountpoint;
//Run the commands
Expand All @@ -287,6 +288,14 @@ void MenuItem::unmountItem(){
result = tr("It is now safe to remove the device");
}
}else{
if(!force){
if(QMessageBox::Yes == QMessageBox::question(0,tr("Device Busy"),
tr("The device appears to be busy. Would you like to unmount it anyway?")+"\n\n"+tr("NOTE: This is generally not recommended unless you are sure that you don't have any applications using the device."),
QMessageBox::Yes | QMessageBox::No, QMessageBox::No) ){
unmountItem(true); //force the unmount recursively
return;
}
}
qDebug() << "pc-mounttray: Error unmounting mountpoint:" << mountpoint;
qDebug() << " - Error message:" << output;
title = QString( tr("Error: %1 could not be unmounted") ).arg(devLabel->text());
Expand Down
2 changes: 1 addition & 1 deletion src-qt4/pc-mounttray/menuItem.h
Expand Up @@ -59,7 +59,7 @@ class MenuItem : public QWidgetAction
QCheckBox* checkAutomount;

//void mountItem();
void unmountItem();
void unmountItem(bool force = false);
void updateSizes();
QString getSizeDisplay(int);
bool checkSavedAutoMount();
Expand Down

0 comments on commit 22f21be

Please sign in to comment.