Skip to content
Browse files

Clean up the new device detection routine - only show full disks that…

… are not currently in use.
  • Loading branch information...
1 parent 9a02460 commit b98ade447b3d807a6506754d3bef24c17e74cd81 @beanpole135 beanpole135 committed Oct 17, 2013
Showing with 12 additions and 3 deletions.
  1. +7 −2 lp-gui/LPGUtils.cpp
  2. +5 −1 lp-gui/LPMain.cpp
View
9 lp-gui/LPGUtils.cpp
@@ -232,6 +232,11 @@ QStringList LPGUtils::listAvailableHardDisks(){
QDir dev("/dev");
QStringList filters;
filters << "ada*" << "da*";
-
- return dev.entryList(filters, QDir::Files | QDir::System | QDir::NoDotAndDotDot, QDir::Name);
+ QStringList devs = dev.entryList(filters, QDir::Files | QDir::System | QDir::NoDotAndDotDot, QDir::Name);
+ //Filter out all the partitions (only keep full devices)
+ for(int i=0; i<devs.length(); i++){
+ devs[i] = devs[i].section("s",0,0,QString::SectionSkipEmpty);
+ }
+ devs.removeDuplicates();
+ return devs;
}
View
6 lp-gui/LPMain.cpp
@@ -449,7 +449,11 @@ void LPMain::menuAddDisk(){
//Get the available disks and remove the current disks
QStringList adisks = LPGUtils::listAvailableHardDisks();
for(int i=0; i<POOLDATA.harddisks.length(); i++){
- adisks.removeAll(POOLDATA.harddisks[i]);
+ adisks.removeAll( POOLDATA.harddisks[i].section("s",0,0,QString::SectionSkipEmpty) );
+ }
+ if(adisks.isEmpty()){
+ QMessageBox::information(this,tr("Attach New Disk"), tr("No available disks could be found"));
+ return;
}
//Find a disk that can be added to the system
bool ok=false;

0 comments on commit b98ade4

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