Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions hassio/src/components/hassio-upload-snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ declare global {
}
}

const MAX_FILE_SIZE = 1 * 1024 * 1024 * 1024; // 1GB

@customElement("hassio-upload-snapshot")
export class HassioUploadSnapshot extends LitElement {
public hass!: HomeAssistant;
Expand All @@ -51,6 +53,20 @@ export class HassioUploadSnapshot extends LitElement {
private async _uploadFile(ev) {
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)) {
showAlertDialog(this, {
title: "Unsupported file format",
Expand Down