From 1dce303ab6f7e2ef5471ad74ab83759af87f72f1 Mon Sep 17 00:00:00 2001 From: localhorst Date: Fri, 12 Dec 2025 22:46:21 +0100 Subject: [PATCH] Defensive drive state (#89) fixes https://git.mosad.xyz/localhorst/reHDD/issues/79 Reviewed-on: https://git.mosad.xyz/localhorst/reHDD/pulls/89 Co-authored-by: localhorst Co-committed-by: localhorst --- src/reHDD.cpp | 2 -- src/shred.cpp | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/reHDD.cpp b/src/reHDD.cpp index a395908..d362463 100644 --- a/src/reHDD.cpp +++ b/src/reHDD.cpp @@ -542,7 +542,6 @@ void reHDD::startShredAllDrives(list *plistDrives) address << (void const *)&(*pTmpDrive); Logger::logThis()->info("Started shred (all) for: " + pTmpDrive->getModelName() + "-" + pTmpDrive->getSerial() + " @" + address.str()); #endif - pTmpDrive->state = Drive::TaskState::SHRED_ACTIVE; thread(ThreadShred, pTmpDrive).detach(); } } @@ -694,7 +693,6 @@ void reHDD::handleEnter() if (tmpSelectedDrive->state == Drive::TaskState::SHRED_SELECTED) { Logger::logThis()->info("Started shred/check for: " + tmpSelectedDrive->getModelName() + "-" + tmpSelectedDrive->getSerial()); - tmpSelectedDrive->state = Drive::TaskState::SHRED_ACTIVE; // task for drive is running --> don't show more task option thread(ThreadShred, tmpSelectedDrive).detach(); } diff --git a/src/shred.cpp b/src/shred.cpp index b2c6a0a..6cddd6c 100644 --- a/src/shred.cpp +++ b/src/shred.cpp @@ -38,6 +38,10 @@ int Shred::shredDrive(Drive *drive, int *ipSignalFd) address << (void const *)&(*drive); Logger::logThis()->info("Shred-Task started - Drive: " + drive->getModelName() + "-" + drive->getSerial() + " @" + address.str()); drive->bWasShredStarted = true; // Mark drive as partly shredded + drive->bWasShredded = false; + drive->setTaskPercentage(0.0); + drive->u32DriveChecksumAfterShredding = UINT32_MAX; + drive->state = Drive::TaskState::SHRED_ACTIVE; #ifdef DRYRUN for (int i = 0; i <= 100; i++)