aarch64 EFI image management
This commit is contained in:
parent
e7605dc289
commit
50df5197d4
6 changed files with 156 additions and 33 deletions
30
storage/utils.go
Normal file
30
storage/utils.go
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
package storage
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func checkExistsOrRemove(path string, overwriteRemove bool) (bool, error) {
|
||||
var removed bool
|
||||
|
||||
_, err := os.Stat(path)
|
||||
if err != nil {
|
||||
if !errors.Is(err, os.ErrNotExist) {
|
||||
return removed, errors.Wrap(err, "stat file")
|
||||
}
|
||||
} else {
|
||||
if overwriteRemove {
|
||||
err = os.Remove(path)
|
||||
if err != nil {
|
||||
return removed, errors.Wrap(err, "remove file")
|
||||
}
|
||||
removed = true
|
||||
} else {
|
||||
return removed, ErrImageAlreadyExists
|
||||
}
|
||||
}
|
||||
|
||||
return removed, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue