Skip to content

Commit

Permalink
Update VueFinder.php
Browse files Browse the repository at this point in the history
  • Loading branch information
n1crack committed Sep 27, 2022
1 parent 8f57df7 commit a4e2851
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/VueFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,13 @@ public function newfolder()
throw new Exception('Invalid folder name.');
}

if ($this->manager->directoryExists($path.DIRECTORY_SEPARATOR.$name)) {
throw new Exception('The folder is exists. Try another name.');
$newPath = $path.DIRECTORY_SEPARATOR.$name;

if ($this->manager->fileExists($newPath) || $this->manager->directoryExists($newPath)) {
throw new Exception('The file/folder is already exists. Try another name.');
}

$this->manager->createDirectory($path.DIRECTORY_SEPARATOR.$name);
$this->manager->createDirectory($newPath);

return $this->index();
}
Expand All @@ -231,12 +233,13 @@ public function newfile()
if (!$name || !strpbrk($name, "\\/?%*:|\"<>") === false) {
throw new Exception('Invalid file name.');
}
$newPath = $path.DIRECTORY_SEPARATOR.$name;

if ($this->manager->fileExists($path.DIRECTORY_SEPARATOR.$name)) {
throw new Exception('The file is exists. Try another name.');
if ($this->manager->fileExists($newPath) || $this->manager->directoryExists($newPath)) {
throw new Exception('The file/folder is already exists. Try another name.');
}

$this->manager->write($path.DIRECTORY_SEPARATOR.$name, '');
$this->manager->write($newPath, '');

return $this->index();
}
Expand Down Expand Up @@ -310,6 +313,10 @@ public function rename()
$path = $this->request->get('path');
$to = $path.DIRECTORY_SEPARATOR.$name;

if ($this->manager->fileExists($to) || $this->manager->directoryExists($to)) {
throw new Exception('The file/folder is already exists.');
}

$this->manager->move($from, $to);

return $this->index();
Expand All @@ -323,7 +330,7 @@ public function move()

foreach ($items as $item) {
$target = $to.DIRECTORY_SEPARATOR.basename($item->path);
if ($this->manager->fileExists($target)) {
if ($this->manager->fileExists($target) || $this->manager->directoryExists($target)) {
throw new Exception('One of the files is already exists.');
}
}
Expand Down Expand Up @@ -416,7 +423,6 @@ public function archive()
*/
public function unarchive()
{

$zipItem = $this->request->get('item');

$zipStream = $this->manager->readStream($zipItem);
Expand Down

0 comments on commit a4e2851

Please sign in to comment.