浏览代码

Check max disk size

Haseeb Qureshie 4 月之前
父节点
当前提交
a828fd58c8
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3 1
      src/lib/WebVM.svelte

+ 3 - 1
src/lib/WebVM.svelte

@@ -18,6 +18,8 @@
 	export let diskLatencies = [];
 	export let activityEventsInterval = 0;
 
+	const MAX_DISK_SIZE = 2_147_483_648; // 2GB
+
 	var term = null;
 	var cx = null;
 	var fitAddon = null;
@@ -279,7 +281,7 @@
 				break;
 			case "bytes":
             	const fileSize = await getLocalDiskImageSize(configObj.diskImageUrl);
-				if (fileSize > 2 * 1024 * 1024 * 1024)
+				if (fileSize > MAX_DISK_SIZE)
                 	throw new Error("Disk image size exceeds the allowed 2GB limit.");
 				blockDevice = await CheerpX.HttpBytesDevice.create(configObj.diskImageUrl);
 				break;