Show error message when file hashing fails

This commit is contained in:
Chris Kankiewicz
2020-04-04 23:45:12 -07:00
parent fca828fe30
commit 7cc79c2f19
2 changed files with 20 additions and 5 deletions

View File

@@ -22,7 +22,11 @@
<content class="flex justify-center items-center p-4">
<div class="overflow-x-auto">
<table class="table-auto">
<p class="font-thin text-2xl text-gray-600 m-4" v-if="error">
{{ error }}
</p>
<table class="table-auto" v-else>
<tbody>
<tr v-for="(hash, title) in this.hashes" v-bind:key="hash">
<td class="border font-bold px-4 py-2">{{ title }}</td>
@@ -44,6 +48,7 @@
export default {
data: function () {
return {
error: null,
filePath: 'file-info.txt',
hashes: {
'md5': '••••••••••••••••••••••••••••••••',
@@ -69,14 +74,16 @@
await axios.get('?info=' + filePath).then(function (response) {
this.hashes = response.data.hashes;
this.loading = false;
}.bind(this)).catch(
response => this.hide() && console.error(response)
);
}.bind(this)).catch(function (error) {
this.error = error.response.data.message;
}.bind(this));
this.loading = false;
},
hide() {
this.visible = false;
this.loading = true;
this.error = null;
}
},
mounted() {

View File

@@ -48,10 +48,18 @@ class FileInfoController
);
if (! $file->isFile()) {
$response->getBody()->write(json_encode([
'message' => $this->translator->trans('error.file_not_found'),
]));
return $response->withStatus(404, $this->translator->trans('error.file_not_found'));
}
if ($file->getSize() >= $this->container->get('max_hash_size')) {
$response->getBody()->write(json_encode([
'message' => $this->translator->trans('error.file_size_exceeded'),
]));
return $response->withStatus(500, $this->translator->trans('error.file_size_exceeded'));
}