let idp init private key also if the file already exists and is empty

This commit is contained in:
Willy Kloucek
2022-08-15 11:09:54 +02:00
parent 24edee982d
commit 19e3169800
2 changed files with 10 additions and 4 deletions

View File

@@ -0,0 +1,6 @@
Bugfix: Autocreate IDP private key also if file exists but is empty
We've fixed the behavior for the IDP private key generation so that
a private key is also generated when the file already exists but is empty.
https://github.com/owncloud/ocis/pull/4394

View File

@@ -161,12 +161,12 @@ func ensureEncryptionSecretExists(path string) error {
func ensureSigningPrivateKeyExists(paths []string) error {
for _, path := range paths {
_, err := os.Stat(path)
if err == nil {
// If the file exists we can just return
file, err := os.Stat(path)
if err == nil && file.Size() > 0 {
// If the file exists and is not empty we can just return
return nil
}
if !errors.Is(err, fs.ErrNotExist) {
if !errors.Is(err, fs.ErrNotExist) && file.Size() > 0 {
return err
}