Skip to content

Commit

Permalink
getMetadata() generate if not found
Browse files Browse the repository at this point in the history
Signed-off-by: Maxence Lange <[email protected]>
  • Loading branch information
ArtificialOwl committed Oct 19, 2023
1 parent d978e64 commit 23ba95e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/private/FilesMetadata/FilesMetadataManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,22 @@ public function __construct(

/**
* @param int $fileId
* @param bool $generate - returns an empty FilesMetadata if FilesMetadataNotFoundException
*
* @return IFilesMetadata
* @throws FilesMetadataNotFoundException
*/
public function getMetadata(int $fileId): IFilesMetadata {
return $this->metadataRequestService->getMetadataFromFileId($fileId);
}
public function getMetadata(int $fileId, bool $generate = false): IFilesMetadata {
try {
return $this->metadataRequestService->getMetadataFromFileId($fileId);
} catch (FilesMetadataNotFoundException $e) {
if ($generate) {
return new FilesMetadata($fileId, true);
}

throw $e;
}
}

public function refreshMetadata(
Node $node,
Expand Down

0 comments on commit 23ba95e

Please sign in to comment.