Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Filesystem/FlysystemAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ public function exists($path)
return parent::exists($path);
}

public function put($path, $contents)
{
// Flysystem creates any missing parent directories as part of the write. Making
// the directory first is another request per write on a remote disk, and on
// object stores it leaves an empty "directory" object behind each time.
return $this->filesystem->put($this->normalizePath($path), $contents);
}

public function getFiles($path, $recursive = false)
{
return $this->collection(
Expand Down
10 changes: 10 additions & 0 deletions tests/Filesystem/FlysystemAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,14 @@ public function it_throws_an_exception_when_requesting_absolute_paths()

$this->adapter->withAbsolutePaths();
}

#[Test]
public function putting_a_file_does_not_make_the_directory_first()
{
$filesystem = \Mockery::mock(\Illuminate\Filesystem\FilesystemAdapter::class);
$filesystem->shouldReceive('put')->with('sub/dir/filename.txt', 'Hello World')->once()->andReturnTrue();
$filesystem->shouldNotReceive('makeDirectory');

$this->assertTrue((new FlysystemAdapter($filesystem))->put('sub/dir/filename.txt', 'Hello World'));
}
}
Loading