From ad6a95c21bcaaa505ce3a02a906066fb6b426391 Mon Sep 17 00:00:00 2001 From: localhorst Date: Fri, 16 Aug 2024 10:24:12 +0200 Subject: [PATCH] skip delete if drive was shredded before --- src/delete.cpp | 14 +++++++++----- src/reHDD.cpp | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/delete.cpp b/src/delete.cpp index b7ca4bd..94560ab 100644 --- a/src/delete.cpp +++ b/src/delete.cpp @@ -32,11 +32,15 @@ void Delete::deleteDrive(Drive *drive) const char *cpComand = sCMD.c_str(); // cout << "delete: " << cpComand << endl; - FILE *deleteCmdOutput = popen(cpComand, "r"); - - while ((getline(&cLine, &len, deleteCmdOutput)) != -1) + if (drive->bWasShredStarted == false) { - // wipefs running + //only start delete if the drive was not shredded before + FILE *deleteCmdOutput = popen(cpComand, "r"); + + while ((getline(&cLine, &len, deleteCmdOutput)) != -1) + { + // wipefs running + } + pclose(deleteCmdOutput); } - pclose(deleteCmdOutput); } diff --git a/src/reHDD.cpp b/src/reHDD.cpp index e05ee75..9338242 100644 --- a/src/reHDD.cpp +++ b/src/reHDD.cpp @@ -585,7 +585,7 @@ void reHDD::handleEnter() thread(ThreadShred, pTmpDrive).detach(); } - if ((getSelectedDrive()->state == Drive::TaskState::DELETE_SELECTED) && (getSelectedDrive()->bWasShredStarted == false)) + if (getSelectedDrive()->state == Drive::TaskState::DELETE_SELECTED) { Logger::logThis()->info("Started delete for: " + getSelectedDrive()->getModelName() + "-" + getSelectedDrive()->getSerial()); getSelectedDrive()->state = Drive::TaskState::DELETE_ACTIVE;