mirror of
https://github.com/DirectoryLister/DirectoryLister.git
synced 2025-08-25 15:01:16 +02:00
Show error message when file hashing fails
This commit is contained in:
@@ -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() {
|
||||
|
@@ -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'));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user