Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix up the mount tray to detect when a device has been automounted by…

… something else and let the mounttray be able to unmount it when prompted
  • Loading branch information...
commit 940aaf0ed3cfa3359de6cbc45285faeed208d039 1 parent 7369d56
Ken Moore beanpole135 authored

Showing 1 changed file with 19 additions and 11 deletions. Show diff stats Hide diff stats

  1. +19 11 src-qt4/pc-mounttray/menuItem.cpp
30 src-qt4/pc-mounttray/menuItem.cpp
@@ -105,11 +105,23 @@ bool MenuItem::isConnected(){
105 105
106 106 bool MenuItem::isMounted(){
107 107 //Check if device is mounted
  108 + QStringList chk = pcbsd::Utils::runShellCommand("mount");
  109 + bool mounted=false;
  110 + for(int i=0; i<chk.length(); i++){
  111 + mounted = chk[i].contains(device) || chk[i].contains(devLabel->text()) || chk[i].contains(devLabel->text().replace(" ","-"));
  112 + if(mounted){
  113 + //Save the mountpoint if it is mounted
  114 + mountpoint = chk[i].section(" on ",1,10).section("(",0,0).simplified();
  115 + break;
  116 + }
  117 + }
  118 + return mounted;
  119 + /*
108 120 QString chk = pcbsd::Utils::runShellCommandSearch("mount",device);
109 121 if(chk.isEmpty() ){ chk = pcbsd::Utils::runShellCommandSearch("mount",devLabel->text().replace(" ","-")); }
110   -
111 122 if(chk.isEmpty() ){ return FALSE; }
112 123 else{ return TRUE; }
  124 + */
113 125 }
114 126
115 127 //Cleanup function
@@ -247,21 +259,17 @@ void MenuItem::mountItem(){
247 259
248 260 void MenuItem::unmountItem(){
249 261 //Unmount the device
250   -
  262 +
251 263 //Check to see if the current mountpoint exists or if it is somewhere else
252 264 if( !QFile::exists(mountpoint) ){
253   - if( isMounted() ){ //double check that it is actually mounted
254   - //mounted someplace else - find it
255   - QString output = pcbsd::Utils::runShellCommandSearch("mount",device);
256   - mountpoint = output.section(" on ",1,1).section(" (",0,0).replace(" ","-");
257   - }else{
  265 + if( !isMounted() ){ //double check that it is actually mounted (and fix the mountpoint)
258 266 //it is not mounted to begin with
259 267 return;
260 268 }
261 269 }
262   -
263   - QString cmd1 = "umount " + mountpoint;
264   - QString cmd2 = "rmdir " + mountpoint;
  270 + //Make sure there are no spaces in the mounpoint path
  271 + QString cmd1 = "umount \"" + mountpoint +"\"";
  272 + QString cmd2 = "rmdir \"" + mountpoint +"\"";
265 273 qDebug() << "Unmounting device from" << mountpoint;
266 274 //Run the commands
267 275 QStringList output;
@@ -296,7 +304,7 @@ void MenuItem::updateSizes(){
296 304 //this method only works if the device is currently mounted
297 305 bool ok = FALSE;
298 306 if(isMounted()){
299   - QString cmd = "df "+mountpoint;
  307 + QString cmd = "df \""+mountpoint+"\"";
300 308 QStringList output = systemCMD(cmd); //make sure we use the one with a 1K blocksize
301 309 if(output.length() > 1){
302 310 //parse the output (1K blocks) and save them

0 comments on commit 940aaf0

Please sign in to comment.
Something went wrong with that request. Please try again.