forked from localhorst/reHDD
added feature to start shredding for all drives
This commit is contained in:
@ -178,6 +178,11 @@ void reHDD::ThreadUserInput()
|
||||
}
|
||||
ui->updateTUI(&listDrives, u8SelectedEntry);
|
||||
break;
|
||||
case TUI::UserInput::ShredAll:
|
||||
cout << "ShredAll" << endl;
|
||||
startShredAllDrives(&listDrives);
|
||||
ui->updateTUI(&listDrives, u8SelectedEntry);
|
||||
break;
|
||||
case TUI::UserInput::Enter:
|
||||
//cout << "Enter" << endl;
|
||||
handleEnter();
|
||||
@ -194,13 +199,13 @@ void reHDD::ThreadUserInput()
|
||||
}
|
||||
}
|
||||
|
||||
void reHDD::ThreadShred()
|
||||
void reHDD::ThreadShred(Drive* const pDrive)
|
||||
{
|
||||
if (getSelectedDrive() != nullptr)
|
||||
if (pDrive != nullptr)
|
||||
{
|
||||
getSelectedDrive()->setActionStartTimestamp(); //save timestamp at start of shredding
|
||||
pDrive->setActionStartTimestamp(); //save timestamp at start of shredding
|
||||
Shred* pShredTask = new Shred(); //create new shred task
|
||||
pShredTask->shredDrive(getSelectedDrive(), &fdShredInformPipe[1]); //start new shred task
|
||||
pShredTask->shredDrive(pDrive, &fdShredInformPipe[1]); //start new shred task
|
||||
delete pShredTask; //delete shred task
|
||||
ui->updateTUI(&listDrives, u8SelectedEntry);
|
||||
}
|
||||
@ -279,7 +284,7 @@ void reHDD::filterNewDrives(list <Drive>* plistOldDrives, list <Drive>* plistNew
|
||||
for (itNew = plistNewDrives->begin(); itNew != plistNewDrives->end(); ++itNew)
|
||||
{
|
||||
plistOldDrives->push_back(*itNew);
|
||||
Logger::logThis()->info("Add new drive: " + itNew->getModelName());
|
||||
//Logger::logThis()->info("Add new drive: " + itNew->getModelName());
|
||||
}
|
||||
plistNewDrives->clear();
|
||||
}
|
||||
@ -291,7 +296,7 @@ void reHDD::filterNewDrives(list <Drive>* plistOldDrives, list <Drive>* plistNew
|
||||
*/
|
||||
void reHDD::searchDrives(list <Drive>* plistDrives)
|
||||
{
|
||||
Logger::logThis()->info("--> search drives <--");
|
||||
//Logger::logThis()->info("--> search drives <--");
|
||||
char * cLine = NULL;
|
||||
size_t len = 0;
|
||||
|
||||
@ -329,7 +334,7 @@ void reHDD::filterIgnoredDrives(list <Drive>* plistDrives)
|
||||
|
||||
for(string sLine; getline( input, sLine );)
|
||||
{
|
||||
Logger::logThis()->info("read uuid: " + sLine);
|
||||
//Logger::logThis()->info("read uuid: " + sLine);
|
||||
vtlIgnoredDevices.emplace_back(sLine); //add found path and uuid from ignore file to vector
|
||||
}
|
||||
//loop through found entries in ingnore file
|
||||
@ -377,6 +382,26 @@ void reHDD::filterIgnoredDrives(list <Drive>* plistDrives)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief start shred for all drives
|
||||
* \param pointer of list <Drive>* plistDrives
|
||||
* \return void
|
||||
*/
|
||||
void reHDD::startShredAllDrives(list <Drive>* plistDrives)
|
||||
{
|
||||
list <Drive>::iterator it;
|
||||
for (it = plistDrives->begin(); it != plistDrives->end(); ++it)
|
||||
{
|
||||
if(it->state == Drive::NONE)
|
||||
{
|
||||
it->state = Drive::SHRED_ACTIVE;
|
||||
Logger::logThis()->info("all start: " + it->getSerial());
|
||||
Drive* pTmpDrive = iterator_to_pointer<Drive, std::list<Drive>::iterator > (it);
|
||||
thread(ThreadShred, std::ref(pTmpDrive)).detach();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief print drives with all information
|
||||
* \param pointer of list <Drive>* plistDrives
|
||||
@ -454,7 +479,7 @@ void reHDD::handleArrowKey(TUI::UserInput userInput)
|
||||
break;
|
||||
}
|
||||
|
||||
Logger::logThis()->info("ArrowKey - selected drive: " + to_string(u8SelectedEntry));
|
||||
//Logger::logThis()->info("ArrowKey - selected drive: " + to_string(u8SelectedEntry));
|
||||
}
|
||||
|
||||
void reHDD::handleEnter()
|
||||
@ -466,7 +491,8 @@ void reHDD::handleEnter()
|
||||
Logger::logThis()->info("Started shred for: " + getSelectedDrive()->getModelName() + "-" + getSelectedDrive()->getSerial());
|
||||
getSelectedDrive()->state = Drive::TaskState::SHRED_ACTIVE;
|
||||
//task for drive is running --> don´t show more task options
|
||||
thread(ThreadShred).detach();
|
||||
Drive* pTmpDrive = getSelectedDrive();
|
||||
thread(ThreadShred, std::ref(pTmpDrive)).detach();
|
||||
}
|
||||
|
||||
if(getSelectedDrive()->state == Drive::TaskState::DELETE_SELECTED)
|
||||
|
Reference in New Issue
Block a user