feature/ipc_mgsqueue_printer (#57)

closes localhorst/reHDD#56

Co-authored-by: localhorst <localhorst@mosad.xyz>
Reviewed-on: localhorst/reHDD#57
This commit is contained in:
2022-11-24 20:41:23 +01:00
parent 6f5e0584bf
commit 8938fe5047
11 changed files with 178 additions and 30 deletions

View File

@ -15,7 +15,7 @@ static std::mutex mxDrives;
list <Drive> listNewDrives; //store found drives that are updated every 5sec
static list <Drive> listDrives; //stores all drive data from scann thread
static list <Drive> listDrives; //stores all drive data from scan thread
TUI *ui;
@ -46,7 +46,7 @@ void reHDD::app_logic(void)
pipe(fdNewDrivesInformPipe);
pipe(fdShredInformPipe);
thread thDevices(ThreadScannDevices); //start thread that scanns for drives
thread thDevices(ThreadScanDevices); //start thread that scans for drives
thread thUserInput(ThreadUserInput); //start thread that reads user input
thread thCheckFrozenDrives(ThreadCheckFrozenDrives); //start thread that checks timeout for drives
@ -98,7 +98,7 @@ Drive* reHDD::getSelectedDrive()
}
}
void reHDD::ThreadScannDevices()
void reHDD::ThreadScanDevices()
{
while(true)
{
@ -221,7 +221,7 @@ void reHDD::ThreadDelete()
getSelectedDrive()->setActionStartTimestamp(); //save timestamp at start of deleting
Delete::deleteDrive(getSelectedDrive()); //blocking, no thread
getSelectedDrive()->state = Drive::TaskState::NONE; //delete finished
getSelectedDrive()->bWasDeleteted = true;
getSelectedDrive()->bWasDeleted = true;
Logger::logThis()->info("Finished delete for: " + getSelectedDrive()->getModelName() + "-" + getSelectedDrive()->getSerial());
ui->updateTUI(&listDrives, u8SelectedEntry);
}
@ -230,7 +230,7 @@ void reHDD::ThreadDelete()
void reHDD::filterNewDrives(list <Drive>* plistOldDrives, list <Drive>* plistNewDrives)
{
list <Drive>::iterator itOld; //Iterator for current (old) drive list
list <Drive>::iterator itNew; //Iterator for new drive list that was created from to scann thread
list <Drive>::iterator itNew; //Iterator for new drive list that was created from to scan thread
//remove offline old drives from previously run
for (itOld = plistOldDrives->begin(); itOld != plistOldDrives->end();)
@ -263,9 +263,9 @@ void reHDD::filterNewDrives(list <Drive>* plistOldDrives, list <Drive>* plistNew
//copy new smart data to existing drive
itOld->setDriveSMARTData(itNew->getModelFamily(), itNew->getModelName(), itNew->getSerial(), itNew->getCapacity(), itNew->getErrorCount(), itNew->getPowerOnHours(), itNew->getPowerCycles(), itNew->getTemperature());
#ifdef LOG_LEVEL_HIGH
Logger::logThis()->info("Delete new drive, because allready attached: " + itNew->getModelName());
Logger::logThis()->info("Delete new drive, because already attached: " + itNew->getModelName());
#endif
itNew = plistNewDrives->erase(itNew); //This drive is allready attached, remove from new list
itNew = plistNewDrives->erase(itNew); //This drive is already attached, remove from new list
}
else
{
@ -334,15 +334,15 @@ void reHDD::searchDrives(list <Drive>* plistDrives)
*/
void reHDD::filterIgnoredDrives(list <Drive>* plistDrives)
{
list<tuple<string>> vtlIgnoredDevices; //store drives from ingnore file
ifstream input( "ignoreDrives.conf" ); //read ingnore file
list<tuple<string>> vtlIgnoredDevices; //store drives from ignore file
ifstream input( "ignoreDrives.conf" ); //read ignore file
for(string sLine; getline( input, 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
//loop through found entries in ignore file
for(auto row : vtlIgnoredDevices)
{
list <Drive>::iterator it;