From ad2ae68ffc4ae581cffa2e6f86c2e8a32ceebb99 Mon Sep 17 00:00:00 2001 From: Glen Huang Date: Sat, 6 Sep 2025 21:05:36 +0800 Subject: [PATCH] fix changing between a secret file and a directory with the same name --- pkgs/sops-install-secrets/main.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/sops-install-secrets/main.go b/pkgs/sops-install-secrets/main.go index 94f6c8e..444e246 100644 --- a/pkgs/sops-install-secrets/main.go +++ b/pkgs/sops-install-secrets/main.go @@ -966,8 +966,8 @@ func handleModifications(isDry bool, logcfg loggingConfig, symlinkPath string, s // Read the old file oldData, err := os.ReadFile(oldPath) if err != nil { - if os.IsNotExist(err) { - // File did not exist before + // File did not exist before or the path changed from a file to a directory or vice versa + if os.IsNotExist(err) || errors.Is(err, syscall.ENOTDIR) || errors.Is(err, syscall.EISDIR) { restart = append(restart, secret.RestartUnits...) reload = append(reload, secret.ReloadUnits...) newSecrets[secret.Name] = true @@ -997,8 +997,8 @@ func handleModifications(isDry bool, logcfg loggingConfig, symlinkPath string, s // Read the old file oldData, err := os.ReadFile(oldPath) if err != nil { - if os.IsNotExist(err) { - // File did not exist before + // File did not exist before or the path changed from a file to a directory or vice versa + if os.IsNotExist(err) || errors.Is(err, syscall.ENOTDIR) || errors.Is(err, syscall.EISDIR) { restart = append(restart, template.RestartUnits...) reload = append(reload, template.ReloadUnits...) newTemplates[template.Name] = true