|
46 | 46 | use OCP\IUserManager; |
47 | 47 | use Psr\Log\LoggerInterface; |
48 | 48 | use stdClass; |
| 49 | +use TypeError; |
49 | 50 |
|
50 | 51 | /** |
51 | 52 | * @psalm-import-type LibresignEnvelopeChildFile from ResponseDefinitions |
@@ -660,22 +661,22 @@ public function delete(int $fileId, bool $deleteFile = true): void { |
660 | 661 | $this->idDocsMapper->deleteByFileId($file->getId()); |
661 | 662 | $this->fileMapper->delete($file); |
662 | 663 | if ($deleteFile) { |
663 | | - if ($file->getSignedNodeId()) { |
664 | | - try { |
665 | | - $signedNextcloudFile = $this->folderService->getFileByNodeId($file->getSignedNodeId()); |
666 | | - $parentFolder = $signedNextcloudFile->getParent(); |
667 | | - $signedNextcloudFile->delete(); |
668 | | - $this->deleteEmptyFolder($parentFolder); |
669 | | - } catch (NotFoundException) { |
670 | | - } |
671 | | - } |
672 | | - try { |
673 | | - $nextcloudFile = $this->folderService->getFileByNodeId($file->getNodeId()); |
674 | | - $parentFolder = $nextcloudFile->getParent(); |
675 | | - $nextcloudFile->delete(); |
676 | | - $this->deleteEmptyFolder($parentFolder); |
677 | | - } catch (NotFoundException) { |
678 | | - } |
| 664 | + $this->deletePhysicalFileIfPossible($file->getSignedNodeId()); |
| 665 | + $this->deletePhysicalFileIfPossible($file->getNodeId()); |
| 666 | + } |
| 667 | + } |
| 668 | + |
| 669 | + private function deletePhysicalFileIfPossible(?int $nodeId): void { |
| 670 | + if ($nodeId === null) { |
| 671 | + return; |
| 672 | + } |
| 673 | + |
| 674 | + try { |
| 675 | + $nextcloudFile = $this->folderService->getFileByNodeId($nodeId); |
| 676 | + $parentFolder = $nextcloudFile->getParent(); |
| 677 | + $nextcloudFile->delete(); |
| 678 | + $this->deleteEmptyFolder($parentFolder); |
| 679 | + } catch (NotFoundException|TypeError) { |
679 | 680 | } |
680 | 681 | } |
681 | 682 |
|
|
0 commit comments