Skip to content

Commit

Permalink
Flysystem v3 update
Browse files Browse the repository at this point in the history
  • Loading branch information
4rn0 committed May 18, 2022
1 parent 976048e commit cc61323
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/ImageOptimizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ private function ensureOnLocalFileSystem(Asset $asset)

$source = $asset->disk()->filesystem()->readStream($path);
$target = $asset->basename();
Storage::disk('local')->putStream($target, $source);

Storage::disk('local')->writeStream($target, $source);

$path = Storage::disk('local')->path($target);

Expand All @@ -86,7 +86,7 @@ private function ensureOnCorrectFileSystem(Asset $asset)
$source = Storage::disk('local')->readStream($path);
$target = $asset->resolvedPath();

$asset->disk()->filesystem()->putStream($target, $source);
$asset->disk()->filesystem()->writeStream($target, $source);

Storage::disk('local')->delete($path);

Expand Down Expand Up @@ -126,7 +126,7 @@ private function setOriginalSize(Asset $asset)
if (!isset($data['original_size'])) {

$data['original_size'] = $asset->disk()->size( $asset->path() );

$asset->set('imageoptimizer', $data);
$asset->save();

Expand Down Expand Up @@ -154,7 +154,7 @@ private function setCurrentSize(Asset $asset)
$asset->save();

return $asset;

}

/**
Expand All @@ -164,15 +164,15 @@ private function setCurrentSize(Asset $asset)
*/
public function optimizeGlide($path)
{

$cache_key = 'imageoptimizer:' . $path;

$base = config('statamic.assets.image_manipulation.cache') ? config('statamic.assets.image_manipulation.cache_path') : storage_path('statamic/glide');
$path = realpath($base . '/' . $path);

if (cache()->get($cache_key, false) !== filemtime($path))
{

$this->optimizePath($path);
cache()->put($cache_key, filemtime($path));

Expand Down Expand Up @@ -367,7 +367,7 @@ private function log($message, $context = [])
if (config('statamic.imageoptimizer.log'))
{

Log::info($message, $context);
Log::info($message, $context);

}

Expand Down

0 comments on commit cc61323

Please sign in to comment.