Browse Source

Extensions: fix call to set/remove symlinks

Visman 1 year ago
parent
commit
568e119a79
2 changed files with 15 additions and 5 deletions
  1. 5 2
      app/Models/Extension/Extension.php
  2. 10 3
      app/Models/Extension/Extensions.php

+ 5 - 2
app/Models/Extension/Extension.php

@@ -209,8 +209,11 @@ class Extension extends Model
                         $link = $this->c->DIR_PUBLIC . '/' . \trim($cur['link'], '\\/');
 
                         if (
-                            \is_file($link)
-                            || \is_dir($link)
+                            ! \is_link($link)
+                            && (
+                                \is_file($link)
+                                || \is_dir($link)
+                            )
                         ) {
                             return ['Link \'%s\' already exists', $cur['link']];
                         }

+ 10 - 3
app/Models/Extension/Extensions.php

@@ -347,7 +347,9 @@ class Extensions extends Manager
             'fileData' => $ext->fileData,
         ]);
 
-        $this->removeSymlinks($ext);
+        if ($oldStatus) {
+            $this->removeSymlinks($ext);
+        }
 
         if (true !== $this->updateCommon($ext)) {
             $this->error = 'An error occurred in updateCommon';
@@ -355,9 +357,8 @@ class Extensions extends Manager
             return false;
         }
 
-        $this->setSymlinks($ext);
-
         if ($oldStatus) {
+            $this->setSymlinks($ext);
             $this->updateIndividual();
         }
 
@@ -558,6 +559,9 @@ class Extensions extends Manager
         return $result;
     }
 
+    /**
+     * Создает симлинки для расширения
+     */
     protected function setSymlinks(Extension $ext): bool
     {
         $data = $this->loadDataFromFile($this->commonFile);
@@ -570,6 +574,9 @@ class Extensions extends Manager
         return true;
     }
 
+    /**
+     * Удаляет симлинки расширения
+     */
     protected function removeSymlinks(Extension $ext): bool
     {
         $data = $this->loadDataFromFile($this->commonFile);