Improve get partitions and reset spec (#530)

Co-authored-by: Dimitris Karakasilis <dimitris@karakasilis.me>
This commit is contained in:
Itxaka
2024-09-12 17:24:35 +02:00
committed by GitHub
parent 2c412c4b60
commit d02bc50747
4 changed files with 90 additions and 28 deletions

View File

@@ -114,6 +114,7 @@ func (r ResetAction) Run() (err error) {
defer func() { err = cleanup.Cleanup(err) }()
// Unmount partitions if any is already mounted before formatting
// TODO: Is this needed???
err = e.UnmountPartitions(r.spec.Partitions.PartitionsByMountPoint(true, r.spec.Partitions.Recovery))
if err != nil {
return err
@@ -129,6 +130,10 @@ func (r ResetAction) Run() (err error) {
if r.spec.FormatPersistent {
persistent := r.spec.Partitions.Persistent
if persistent != nil {
err = e.UnmountPartitions(r.spec.Partitions.PartitionsByMountPoint(true, persistent))
if err != nil {
return err
}
err = e.FormatPartition(persistent)
if err != nil {
return err
@@ -140,6 +145,11 @@ func (r ResetAction) Run() (err error) {
if r.spec.FormatOEM {
oem := r.spec.Partitions.OEM
if oem != nil {
// Try to umount
err = e.UnmountPartitions(r.spec.Partitions.PartitionsByMountPoint(true, oem))
if err != nil {
return err
}
err = e.FormatPartition(oem)
if err != nil {
return err