mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 03:06:41 +00:00
Check snapshot size before upload (#7733)
This commit is contained in:
parent
45721eb4fe
commit
0b896ddfb1
@ -27,6 +27,8 @@ declare global {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const MAX_FILE_SIZE = 1 * 1024 * 1024 * 1024; // 1GB
|
||||||
|
|
||||||
@customElement("hassio-upload-snapshot")
|
@customElement("hassio-upload-snapshot")
|
||||||
export class HassioUploadSnapshot extends LitElement {
|
export class HassioUploadSnapshot extends LitElement {
|
||||||
public hass!: HomeAssistant;
|
public hass!: HomeAssistant;
|
||||||
@ -51,6 +53,20 @@ export class HassioUploadSnapshot extends LitElement {
|
|||||||
private async _uploadFile(ev) {
|
private async _uploadFile(ev) {
|
||||||
const file = ev.detail.files[0];
|
const file = ev.detail.files[0];
|
||||||
|
|
||||||
|
if (file.size > MAX_FILE_SIZE) {
|
||||||
|
showAlertDialog(this, {
|
||||||
|
title: "Snapshot file is too big",
|
||||||
|
text: html`The maximum allowed filesize is 1GB.<br />
|
||||||
|
<a
|
||||||
|
href="https://www.home-assistant.io/hassio/haos_common_tasks/#restoring-a-snapshot-on-a-new-install"
|
||||||
|
target="_blank"
|
||||||
|
>Have a look here on how to restore it.</a
|
||||||
|
>`,
|
||||||
|
confirmText: "ok",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!["application/x-tar"].includes(file.type)) {
|
if (!["application/x-tar"].includes(file.type)) {
|
||||||
showAlertDialog(this, {
|
showAlertDialog(this, {
|
||||||
title: "Unsupported file format",
|
title: "Unsupported file format",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user