Changeset View
Changeset View
Standalone View
Standalone View
src/app/Jobs/SharedFolder/DeleteJob.php
Show All 19 Lines | public function handle() | ||||
} | } | ||||
// sanity checks | // sanity checks | ||||
if ($folder->isDeleted()) { | if ($folder->isDeleted()) { | ||||
$this->fail(new \Exception("Shared folder {$this->folderId} is already marked as deleted.")); | $this->fail(new \Exception("Shared folder {$this->folderId} is already marked as deleted.")); | ||||
return; | return; | ||||
} | } | ||||
if (\config('app.with_ldap') && $folder->isLdapReady()) { | |||||
\App\Backends\LDAP::deleteSharedFolder($folder); | \App\Backends\LDAP::deleteSharedFolder($folder); | ||||
$folder->status |= \App\SharedFolder::STATUS_DELETED; | |||||
if ($folder->isLdapReady()) { | |||||
$folder->status ^= \App\SharedFolder::STATUS_LDAP_READY; | $folder->status ^= \App\SharedFolder::STATUS_LDAP_READY; | ||||
$folder->save(); | |||||
machniak: This line was important to be there. If the exception below is thrown the status update… | |||||
} | } | ||||
if ($folder->isImapReady()) { | if ($folder->isImapReady()) { | ||||
if (!\App\Backends\IMAP::deleteSharedFolder($folder)) { | |||||
throw new \Exception("Failed to delete mailbox for shared folder {$this->folderId}."); | |||||
} | |||||
$folder->status ^= \App\SharedFolder::STATUS_IMAP_READY; | $folder->status ^= \App\SharedFolder::STATUS_IMAP_READY; | ||||
} | } | ||||
$folder->status |= \App\SharedFolder::STATUS_DELETED; | |||||
$folder->save(); | $folder->save(); | ||||
} | } | ||||
} | } |
This line was important to be there. If the exception below is thrown the status update wouldn't happen, and we don't want that.