[fsresizer] Document configuration

- Add some notes on configuration of fsresizer
 - Convenience methods for checking validity.
This commit is contained in:
Adriaan de Groot 2018-09-20 15:38:26 +02:00
parent b0db4780bf
commit 499dd2ce83
3 changed files with 26 additions and 1 deletions

View File

@ -85,6 +85,11 @@ ResizeFSJob::prettyName() const
Calamares::JobResult
ResizeFSJob::exec()
{
if ( !isValid() )
return Calamares::JobResult::error(
tr( "Invalid configuration" ),
tr( "The file-system resize job has an invalid configuration "
"and will not run." ) );
return Calamares::JobResult::ok();
}

View File

@ -33,6 +33,12 @@ class PLUGINDLLEXPORT ResizeFSJob : public Calamares::CppJob
Q_OBJECT
public:
/** @brief Size expressions
*
* Sizes can be specified in MiB or percent (of the device they
* are on). This class handles parsing of such strings from the
* config file.
*/
class RelativeSize
{
public:
@ -49,6 +55,11 @@ public:
int value() const { return m_value; }
Unit unit() const { return m_unit; }
constexpr bool isValid() const
{
return ( unit() != None ) && ( value() > 0 );
}
private:
int m_value;
Unit m_unit;
@ -63,6 +74,12 @@ public:
void setConfigurationMap( const QVariantMap& configurationMap ) override;
constexpr bool isValid() const
{
return ( !m_fsname.isEmpty() || !m_devicename.isEmpty() ) &&
m_size.isValid();
}
private:
RelativeSize m_size;
RelativeSize m_atleast;

View File

@ -21,10 +21,13 @@ fs: /
# in percent, so set it to 100. Perhaps a fixed size is
# needed (that would be weird though, since you don't know
# how big the card is), use MiB as suffix in that case.
# If missing, then it's assumed to be 0, and no resizing
# will happen.
size: 100%
# Resizing might not be worth it, though. Set the minimum
# that it must grow; if it cannot grow that much, the
# resizing is skipped. Can be in percentage or absolute
# size, as above.
# size, as above. If missing, then it's assumed to be 0,
# which means resizing is always worthwhile.
atleast: 1000MiB