diff --git a/src/modules/partition/CMakeLists.txt b/src/modules/partition/CMakeLists.txt index 663ba8913..753e8eae6 100644 --- a/src/modules/partition/CMakeLists.txt +++ b/src/modules/partition/CMakeLists.txt @@ -23,6 +23,7 @@ calamares_add_plugin( partition CONFIG_FILE module.conf SOURCES BootLoaderModel.cpp + CheckFileSystemJob.cpp CreatePartitionDialog.cpp CreatePartitionJob.cpp CreatePartitionTableJob.cpp diff --git a/src/modules/partition/CheckFileSystemJob.cpp b/src/modules/partition/CheckFileSystemJob.cpp new file mode 100644 index 000000000..3d353bd7a --- /dev/null +++ b/src/modules/partition/CheckFileSystemJob.cpp @@ -0,0 +1,56 @@ +/* === This file is part of Calamares - === + * + * Copyright 2014, Aurélien Gâteau + * + * Calamares is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Calamares is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Calamares. If not, see . + */ + +#include + +// CalaPM +#include +#include +#include + +CheckFileSystemJob::CheckFileSystemJob( Partition* partition ) + : PartitionJob( partition ) +{} + +QString +CheckFileSystemJob::prettyName() const +{ + QString path = partition()->partitionPath(); + return tr( "Checking file system on partition %1." ).arg( path ); +} + +Calamares::JobResult +CheckFileSystemJob::exec() +{ + FileSystem& fs = partition()->fileSystem(); + + // if we cannot check, assume everything is fine + if ( fs.supportCheck() != FileSystem::cmdSupportFileSystem ) + return Calamares::JobResult::ok(); + + Report report( nullptr ); + bool 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() + ); + + return Calamares::JobResult::ok(); +} diff --git a/src/modules/partition/CheckFileSystemJob.h b/src/modules/partition/CheckFileSystemJob.h new file mode 100644 index 000000000..2eb32d2be --- /dev/null +++ b/src/modules/partition/CheckFileSystemJob.h @@ -0,0 +1,33 @@ +/* === This file is part of Calamares - === + * + * Copyright 2014, Aurélien Gâteau + * + * Calamares is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Calamares is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Calamares. If not, see . + */ + +#ifndef CHECKFILESYSTEMJOB_H +#define CHECKFILESYSTEMJOB_H + +#include + +class CheckFileSystemJob : public PartitionJob +{ +public: + CheckFileSystemJob( Partition* partition ); + + QString prettyName() const override; + Calamares::JobResult exec() override; +}; + +#endif /* CHECKFILESYSTEMJOB_H */ diff --git a/src/modules/partition/ResizePartitionJob.cpp b/src/modules/partition/ResizePartitionJob.cpp index 6b4b18664..d48d4bd25 100644 --- a/src/modules/partition/ResizePartitionJob.cpp +++ b/src/modules/partition/ResizePartitionJob.cpp @@ -40,6 +40,7 @@ #include +#include #include #include @@ -229,6 +230,7 @@ ResizePartitionJob::exec() // Create jobs QList< Calamares::job_ptr > jobs; + jobs << Calamares::job_ptr( new CheckFileSystemJob( partition() ) ); if ( m_partition->roles().has( PartitionRole::Extended ) ) jobs << Calamares::job_ptr( new SetPartGeometryJob( &context, m_newFirstSector, newLength ) ); else diff --git a/src/modules/partition/tests/CMakeLists.txt b/src/modules/partition/tests/CMakeLists.txt index 65e64af57..8eb8c3fc0 100644 --- a/src/modules/partition/tests/CMakeLists.txt +++ b/src/modules/partition/tests/CMakeLists.txt @@ -2,6 +2,7 @@ find_package( Qt5 COMPONENTS Test REQUIRED ) include( ECMAddTests ) set( jobtests_SRCS + ${PartitionModule_SOURCE_DIR}/CheckFileSystemJob.cpp ${PartitionModule_SOURCE_DIR}/CreatePartitionJob.cpp ${PartitionModule_SOURCE_DIR}/CreatePartitionTableJob.cpp ${PartitionModule_SOURCE_DIR}/DeletePartitionJob.cpp