From 49cb6d304d89b30af8736b9816c7e6de1f67ddf1 Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Fri, 17 Jun 2016 13:55:37 +0200 Subject: [PATCH] Add a controlled number of retries to fsck, 2sec apart. --- .../partition/jobs/CheckFileSystemJob.cpp | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/modules/partition/jobs/CheckFileSystemJob.cpp b/src/modules/partition/jobs/CheckFileSystemJob.cpp index 686621db1..3d694f69a 100644 --- a/src/modules/partition/jobs/CheckFileSystemJob.cpp +++ b/src/modules/partition/jobs/CheckFileSystemJob.cpp @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014, Aurélien Gâteau + * Copyright 2016, Teo Mrnjavac * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,6 +26,8 @@ #include #include +#include + CheckFileSystemJob::CheckFileSystemJob( Partition* partition ) : PartitionJob( partition ) {} @@ -55,19 +58,26 @@ CheckFileSystemJob::exec() Report report( nullptr ); bool ok = fs.check( report, partition()->partitionPath() ); - if ( !ok ) + int retries = 0; + const int MAX_RETRIES = 10; + while ( !ok ) { - cDebug() << "Filesystem check failed for" << partition()->partitionPath() - << ", retrying..."; + cDebug() << "Partition" << partition()->partitionPath() + << "might not be ready yet, retrying (" << ++retries + << "/" << MAX_RETRIES << ") ..."; + QThread::sleep( 2 /*seconds*/ ); ok = fs.check( report, partition()->partitionPath() ); - if ( !ok ) - return Calamares::JobResult::error( - tr( "The file system check on partition %1 failed." ) - .arg( partition()->partitionPath() ), - report.toText() - ); + if ( retries == MAX_RETRIES ) + break; } + if ( !ok ) + return Calamares::JobResult::error( + tr( "The file system check on partition %1 failed." ) + .arg( partition()->partitionPath() ), + report.toText() + ); + return Calamares::JobResult::ok(); }