diff --git a/lib/Service/FolderService.php b/lib/Service/FolderService.php index 5c1a52c9f5..ecf33e995e 100644 --- a/lib/Service/FolderService.php +++ b/lib/Service/FolderService.php @@ -72,16 +72,22 @@ public function getFileById(?int $nodeId = null): File { foreach ($mountsContainingFile as $fileInfo) { $this->root->getByIdInPath($nodeId, $fileInfo->getMountPoint()); } + /** @var File[] */ $file = $this->root->getById($nodeId); if ($file) { - /** @var File */ + if (!$file[0]->fopen('r')) { + throw new NotFoundException('Invalid node'); + } return $file[0]; } $folder = $this->root->getUserFolder($this->getUserId()); + /** @var File[] */ $file = $folder->getById($nodeId); if ($file) { - /** @var File */ + if (!$file[0]->fopen('r')) { + throw new NotFoundException('Invalid node'); + } return current($file); } } diff --git a/src/Components/PreviewSignature/PreviewSignature.vue b/src/Components/PreviewSignature/PreviewSignature.vue index 9d008cc56b..d39d2ed224 100644 --- a/src/Components/PreviewSignature/PreviewSignature.vue +++ b/src/Components/PreviewSignature/PreviewSignature.vue @@ -68,13 +68,14 @@ export default { .then(response => { const buffer = Buffer.from(response.data, 'binary').toString('base64') this.imageData = 'data:application/pdf;base64,' + buffer - this.onImageLoad() + this.onImageLoad(true) }) + .catch(() => this.onImageLoad(false)) }, - onImageLoad() { + onImageLoad(status) { this.loading = false this.isLoaded = true - this.$emit('loaded') + this.$emit('loaded', status) }, }, } diff --git a/src/views/Account/partials/Signature.vue b/src/views/Account/partials/Signature.vue index 91ce306784..161d6712e0 100644 --- a/src/views/Account/partials/Signature.vue +++ b/src/views/Account/partials/Signature.vue @@ -78,10 +78,11 @@ export default { data: () => ({ isEditing: false, isSignatureLoaded: false, + signatureExists: true, }), computed: { hasSignature() { - return this.signatureElementsStore.hasSignatureOfType(this.type) + return this.signatureElementsStore.hasSignatureOfType(this.type) && this.signatureExists }, imgSrc() { if (this.signatureElementsStore.signs[this.type]?.value?.startsWith('data:')) { @@ -91,8 +92,9 @@ export default { }, }, methods: { - signatureLoaded() { - this.isSignatureLoaded = true + signatureLoaded(success) { + this.isSignatureLoaded = success + this.signatureExists = success }, edit() { this.isEditing = true