Update media pipelines

This commit is contained in:
Daniel Supernault 2022-12-24 04:30:02 -07:00
parent 1cdc0fe8ed
commit 04c2b041fc
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
2 changed files with 8 additions and 11 deletions

View file

@ -20,6 +20,7 @@ class MediaDeletePipeline implements ShouldQueue
public $timeout = 300; public $timeout = 300;
public $tries = 3; public $tries = 3;
public $maxExceptions = 1; public $maxExceptions = 1;
public $deleteWhenMissingModels = true;
public function __construct(Media $media) public function __construct(Media $media)
{ {
@ -40,32 +41,27 @@ class MediaDeletePipeline implements ShouldQueue
array_pop($e); array_pop($e);
$i = implode('/', $e); $i = implode('/', $e);
if(config_cache('pixelfed.cloud_storage') == true) { if(config('pixelfed.cloud_storage') == true) {
$disk = Storage::disk(config('filesystems.cloud')); $disk = Storage::disk(config('filesystems.cloud'));
if($path) { if($path && $disk->exists($path)) {
$disk->delete($path); $disk->delete($path);
} }
if($thumb) { if($thumb && $disk->exists($thumb)) {
$disk->delete($thumb); $disk->delete($thumb);
} }
if(count($e) > 4 && count($disk->files($i)) == 0) {
$disk->deleteDirectory($i);
}
} }
$disk = Storage::disk(config('filesystems.local')); $disk = Storage::disk(config('filesystems.local'));
if($path && $disk->exists($path)) { if($path && $disk->exists($path)) {
$disk->delete($path); $disk->delete($path);
} }
if($thumb && $disk->exists($thumb)) { if($thumb && $disk->exists($thumb)) {
$disk->delete($thumb); $disk->delete($thumb);
} }
if(count($e) > 4 && count($disk->files($i)) == 0) {
$disk->deleteDirectory($i);
}
$media->forceDelete(); $media->forceDelete();

View file

@ -17,6 +17,7 @@ class MediaStoragePipeline implements ShouldQueue
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $media; protected $media;
public $deleteWhenMissingModels = true;
public function __construct(Media $media) public function __construct(Media $media)
{ {