Commit fa7347b8 authored by Richard Weinhold's avatar Richard Weinhold 🎩

fixes copyTo(flysystem) bug

parent 0536b35a
Pipeline #5411 passed with stages
in 16 seconds
......@@ -127,8 +127,6 @@ class File extends FileSystem
throw new AccessDeniedException('unable to open destination file', 403, $destination->getConstraintViolations());
} elseif ($destination->isFile() && !$destination->isWriteable()) {
throw new AccessDeniedException('unable to write to destination file', 403);
} elseif (!$destination->isFile() && !is_writable($destination->path()->directory)) {
throw new AccessDeniedException('unable to write to destination directory', 403);
}
// ensure the destination-path points to a filename
......@@ -165,8 +163,6 @@ class File extends FileSystem
throw new AccessDeniedException('unable to write to destination file', 403, $destination->getConstraintViolations());
} elseif ($destination->isFile() && !$destination->isWriteable()) {
throw new AccessDeniedException('unable to write to destination file', 403);
} elseif (!$destination->isFile() && !is_writable($destination->path()->directory)) {
throw new AccessDeniedException('unable to write to destination directory', 403);
}
// ensure the destination-path points to a filename
......
......@@ -311,12 +311,18 @@ class Flysystem extends Storage
*/
public function touch(bool $ifNewOnly = false, ?int $time = null, ?int $atime = null): bool
{
$isFile = $this->isFile();
if ($ifNewOnly && $isFile) {
return true;
}
try {
if ($this->flysystem->has($this->path)) {
return $ifNewOnly ? true : $this->flysystem->write($this->path, '');
if (!$isFile) {
return $this->flysystem->write($this->path, '');
}
return $this->flysystem->put($this->path, $this->flysystem->read($this->path));
return $this->flysystem->rename($this->path, $this->path);
} finally {
$this->metadata = null;
}
......@@ -373,11 +379,7 @@ class Flysystem extends Storage
*/
public function writeFromStream($stream): bool
{
if (!is_resource($stream)) {
throw new RuntimeException(sprintf('file-handle must be of type \'resource\' but \'%s\' given', is_object($handle) ? get_class($handle) : gettype($handle)), 500);
}
$this->touch(true);
return $this->flysystem->updateStream($this->path, $stream);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment