From d0765497a44af7ae5e8a1534bb8fc217c3f253b7 Mon Sep 17 00:00:00 2001
From: jurgenhaas <juergen.haas@lakedrops.com>
Date: Wed, 22 Feb 2023 12:03:42 +0100
Subject: [PATCH] Only chown for existing files

---
 Traefik.php | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/Traefik.php b/Traefik.php
index 72e0bc5..c84ab52 100644
--- a/Traefik.php
+++ b/Traefik.php
@@ -184,8 +184,12 @@ class Traefik {
     $upd2 = $this->updateFile($traefikFile, Yaml::dump($this->defaultDockerCompose(), 9, 2));
     if ($upd1 || $upd2) {
       if ($user) {
-        $fs->chown($traefikConfigPath . '/certificates.toml', $user, TRUE);
-        $fs->chown($traefikFile, $user, TRUE);
+        if (file_exists($traefikConfigPath . '/certificates.toml')) {
+          $fs->chown($traefikConfigPath . '/certificates.toml', $user, TRUE);
+        }
+        if (file_exists($traefikFile)) {
+          $fs->chown($traefikFile, $user, TRUE);
+        }
       }
       $cwd = getcwd();
       chdir($traefikPath);
-- 
GitLab