Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
temaotl committed Jul 29, 2024
1 parent 3c922e5 commit f2844bc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 0 additions & 2 deletions app/Jobs/FolderAddEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ public function handle(): void
->where('approved', 1)
->get();

$diskName = config('storageCfg.name');

foreach ($federationMembershipId as $fedId) {

$federation = Federation::where('id', $fedId->federation_id)->first();
Expand Down
1 change: 0 additions & 1 deletion app/Jobs/FolderDeleteEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public function handle(): void

$entity = $this->entity;
$federations = $entity->federations;
$diskName = config('storageCfg.name');
foreach ($federations as $federation) {

try {
Expand Down
10 changes: 6 additions & 4 deletions app/Jobs/FolderDeleteMembership.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,27 @@ public function handle(): void
$diskName = config('storageCfg.name');

try {
$pathToFile = FederationService::getFederationFolder($federation).'/'.$entity->file;
$pathToDirectory = FederationService::getFederationFolder($federation);

} catch (\Exception $e) {
$this->fail($e);
}

return;
}
$pathToFile = $federation->xml_id.'/'.$entity->file;
Log::info($pathToFile);
if (! Storage::disk($diskName)->exists($pathToFile)) {
NotificationService::sendModelNotification($entity, new MembershipRejected($entity->entityid, $federation->name));

return;
}

$pathToDirectory = Storage::disk($diskName)->path($federation->name);
$lockKey = 'directory-'.md5($pathToDirectory).'-lock';
$lock = Cache::lock($lockKey, 61);

try {
$lock->block(61);
EntityFacade::deleteEntityMetadataFromFolder($entity->file, $federation->xml_id);

RunMdaScript::dispatch($federation, $lock->owner());
} catch (Exception $e) {
$this->fail($e);
Expand Down
7 changes: 4 additions & 3 deletions app/Observers/MembershipObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ class MembershipObserver
*/
public function created(Membership $membership): void
{
//
if ($membership->approved == 1) {
FolderAddMembership::dispatch($membership);
}
}

/**
Expand All @@ -34,7 +36,6 @@ public function deleted(Membership $membership): void
$entity = $membership->entity;
$federation = $membership->federation;
FolderDeleteMembership::dispatch($entity, $federation);

}

/**
Expand All @@ -50,6 +51,6 @@ public function restored(Membership $membership): void
*/
public function forceDeleted(Membership $membership): void
{
//

}
}

0 comments on commit f2844bc

Please sign in to comment.