diff --git a/app/Console/Commands/ValidateMetaConsole.php b/app/Console/Commands/ValidateMetaConsole.php index f60d0ef..9887141 100644 --- a/app/Console/Commands/ValidateMetaConsole.php +++ b/app/Console/Commands/ValidateMetaConsole.php @@ -98,8 +98,8 @@ private function runMDA(Federation $federation) public function handle() { - $federation = Federation::where('id', 1)->first(); - $this->runMDA($federation); + /* $federation = Federation::where('id', 1)->first(); + $this->runMDA($federation);*/ // $this->fixEntities(); // $this->doc(); diff --git a/app/Jobs/DeleteFederation.php b/app/Jobs/DeleteFederation.php new file mode 100644 index 0000000..941651d --- /dev/null +++ b/app/Jobs/DeleteFederation.php @@ -0,0 +1,58 @@ +federation = $federation; + } + + /** + * Execute the job. + */ + public function handle(): void + { + $diskName = config('storageCfg.name'); + $pathToDirectory = Storage::disk($diskName)->path($this->federation->name); + $lockKey = 'directory-'.md5($pathToDirectory).'-lock'; + $lock = Cache::lock($lockKey, 61); + try { + $lock->block(61); + FederationService::DeleteFederationFolder($this->federation->name); + + } catch (Exception $e) { + $this->fail($e); + } finally { + if ($lock->isOwnedByCurrentProcess()) { + $lock->release(); + } + } + + } +} diff --git a/app/Jobs/FolderDeleteEntity.php b/app/Jobs/FolderDeleteEntity.php index 51c1517..fe348a6 100644 --- a/app/Jobs/FolderDeleteEntity.php +++ b/app/Jobs/FolderDeleteEntity.php @@ -19,7 +19,6 @@ class FolderDeleteEntity implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; - use HandlesJobsFailuresTrait; /** * trait with failure function diff --git a/app/Services/FederationService.php b/app/Services/FederationService.php index 060c534..e223903 100644 --- a/app/Services/FederationService.php +++ b/app/Services/FederationService.php @@ -23,4 +23,10 @@ public static function createFoldersToAllFederation(): void } } } + + public static function DeleteFederationFolder(string $name): void + { + $diskName = config('storageCfg.name'); + Storage::disk($diskName)->deleteDirectory($name); + } }