mirror of https://github.com/cutefishos/calamares
[partition] Add a job to handle automount behavior
- while here, nudge CalamaresUtils automount API a little, since it doesn't really need an rvalue-ref.main
parent
f3752e200a
commit
1704ad5977
@ -0,0 +1,39 @@
|
||||
/* === This file is part of Calamares - <https://calamares.io> ===
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2021 Adriaan de Groot <groot@kde.org>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* Calamares is Free Software: see the License-Identifier above.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "AutoMountManagementJob.h"
|
||||
|
||||
#include "utils/Logger.h"
|
||||
|
||||
AutoMountManagementJob::AutoMountManagementJob( bool disable )
|
||||
: m_disable( disable )
|
||||
{
|
||||
}
|
||||
|
||||
QString
|
||||
AutoMountManagementJob::prettyName() const
|
||||
{
|
||||
return tr( "Manage auto-mount settings" );
|
||||
}
|
||||
|
||||
Calamares::JobResult
|
||||
AutoMountManagementJob::exec()
|
||||
{
|
||||
cDebug() << "this" << Logger::Pointer( this ) << "value" << Logger::Pointer( m_stored.get() );
|
||||
if ( m_stored )
|
||||
{
|
||||
CalamaresUtils::Partition::automountRestore( m_stored );
|
||||
m_stored.reset();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_stored = CalamaresUtils::Partition::automountDisable( m_disable );
|
||||
}
|
||||
return Calamares::JobResult::ok();
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
/* === This file is part of Calamares - <https://calamares.io> ===
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2021 Adriaan de Groot <groot@kde.org>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* Calamares is Free Software: see the License-Identifier above.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PARTITION_AUTOMOUNTMANAGEMENTJOB_H
|
||||
#define PARTITION_AUTOMOUNTMANAGEMENTJOB_H
|
||||
|
||||
#include "Job.h"
|
||||
|
||||
#include "partition/AutoMount.h"
|
||||
|
||||
/**
|
||||
* This job sets automounting to a specific value, and when run a
|
||||
* second time, **re**sets to the original value. See the documentation
|
||||
* for CalamaresUtils::Partition::automountDisable() for details.
|
||||
* Use @c true to **disable** automounting.
|
||||
*
|
||||
* Effectively: queue the **same** job twice; the first time it runs
|
||||
* it will set the automount behavior, and the second time it
|
||||
* restores the original.
|
||||
*
|
||||
*/
|
||||
class AutoMountManagementJob : public Calamares::Job
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AutoMountManagementJob( bool disable = true );
|
||||
|
||||
QString prettyName() const override;
|
||||
Calamares::JobResult exec() override;
|
||||
|
||||
private:
|
||||
bool m_disable;
|
||||
decltype( CalamaresUtils::Partition::automountDisable( true ) ) m_stored;
|
||||
};
|
||||
|
||||
#endif /* PARTITION_AUTOMOUNTMANAGEMENTJOB_H */
|
Loading…
Reference in New Issue