Skip to content

Commit 9f688d6

Browse files
authored
Don't write meta when we should only be generating it (#259)
1 parent 3e19212 commit 9f688d6

File tree

1 file changed

+2
-24
lines changed

1 file changed

+2
-24
lines changed

src/Assets/Asset.php

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,14 @@
33
namespace Statamic\Eloquent\Assets;
44

55
use Illuminate\Database\Eloquent\Model;
6-
use Illuminate\Support\Facades\Cache;
76
use Statamic\Assets\Asset as FileAsset;
87
use Statamic\Assets\AssetUploader as Uploader;
98
use Statamic\Contracts\Assets\Asset as AssetContract;
109
use Statamic\Data\HasDirtyState;
11-
use Statamic\Events\AssetUploaded;
1210
use Statamic\Facades\Blink;
1311
use Statamic\Facades\Path;
1412
use Statamic\Support\Arr;
1513
use Statamic\Support\Str;
16-
use Symfony\Component\HttpFoundation\File\UploadedFile;
1714

1815
class Asset extends FileAsset
1916
{
@@ -62,8 +59,7 @@ public function meta($key = null)
6259
return $meta;
6360
}
6461

65-
return $this->meta = Cache::rememberForever($this->metaCacheKey(), function () {
66-
$handle = $this->container()->handle().'::'.$this->metaPath();
62+
return Blink::once($this->metaCacheKey(), function () {
6763
if ($model = app('statamic.eloquent.assets.model')::where([
6864
'container' => $this->containerHandle(),
6965
'folder' => $this->folder(),
@@ -72,7 +68,7 @@ public function meta($key = null)
7268
return $model->meta;
7369
}
7470

75-
$this->writeMeta($meta = $this->generateMeta());
71+
$meta = $this->generateMeta();
7672

7773
if (! $meta['data']) {
7874
$meta['data'] = [];
@@ -218,24 +214,6 @@ public function move($folder, $filename = null)
218214
return $this;
219215
}
220216

221-
/**
222-
* Upload a file.
223-
*
224-
* @return $this
225-
*/
226-
public function upload(UploadedFile $file)
227-
{
228-
$path = Uploader::asset($this)->upload($file);
229-
230-
$this
231-
->path($path)
232-
->save();
233-
234-
AssetUploaded::dispatch($this);
235-
236-
return $this;
237-
}
238-
239217
public function getCurrentDirtyStateAttributes(): array
240218
{
241219
return array_merge([

0 commit comments

Comments
 (0)