Add a controlled number of retries to fsck, 2sec apart.

This commit is contained in:
Teo Mrnjavac 2016-06-17 13:55:37 +02:00
parent e7c5a2b1a5
commit 49cb6d304d

View File

@ -1,6 +1,7 @@
/* === This file is part of Calamares - <http://github.com/calamares> === /* === This file is part of Calamares - <http://github.com/calamares> ===
* *
* Copyright 2014, Aurélien Gâteau <agateau@kde.org> * Copyright 2014, Aurélien Gâteau <agateau@kde.org>
* Copyright 2016, Teo Mrnjavac <teo@kde.org>
* *
* Calamares is free software: you can redistribute it and/or modify * Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -25,6 +26,8 @@
#include <kpmcore/fs/filesystem.h> #include <kpmcore/fs/filesystem.h>
#include <kpmcore/util/report.h> #include <kpmcore/util/report.h>
#include <QThread>
CheckFileSystemJob::CheckFileSystemJob( Partition* partition ) CheckFileSystemJob::CheckFileSystemJob( Partition* partition )
: PartitionJob( partition ) : PartitionJob( partition )
{} {}
@ -55,19 +58,26 @@ CheckFileSystemJob::exec()
Report report( nullptr ); Report report( nullptr );
bool ok = fs.check( report, partition()->partitionPath() ); 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() cDebug() << "Partition" << partition()->partitionPath()
<< ", retrying..."; << "might not be ready yet, retrying (" << ++retries
<< "/" << MAX_RETRIES << ") ...";
QThread::sleep( 2 /*seconds*/ );
ok = fs.check( report, partition()->partitionPath() ); ok = fs.check( report, partition()->partitionPath() );
if ( retries == MAX_RETRIES )
break;
}
if ( !ok ) if ( !ok )
return Calamares::JobResult::error( return Calamares::JobResult::error(
tr( "The file system check on partition %1 failed." ) tr( "The file system check on partition %1 failed." )
.arg( partition()->partitionPath() ), .arg( partition()->partitionPath() ),
report.toText() report.toText()
); );
}
return Calamares::JobResult::ok(); return Calamares::JobResult::ok();
} }