🐛 fix: incorrect storage size

This commit is contained in:
2026-06-09 00:38:07 +07:00
parent e64d2e6f1b
commit c4c66c0e8d
4 changed files with 13 additions and 11 deletions
+4 -2
View File
@@ -48,9 +48,11 @@ export const Status: React.FC<StatusProps> = ({
notifications,
verbose,
}) => {
const allspace = typeof status?.allspace === "number" ? status.allspace : 0;
const freespace =
const allspaceMB = typeof status?.allspace === "number" ? status.allspace : 0;
const freespaceMB =
typeof status?.freespace === "number" ? status.freespace : 0;
const allspace = allspaceMB * 1024 * 1024;
const freespace = freespaceMB * 1024 * 1024;
const usedSpace = allspace - freespace;
const freePercentage =
allspace > 0 ? Math.round((freespace / allspace) * 100) : 0;
+5 -5
View File
@@ -195,12 +195,12 @@ export class BeamBoxUploader {
return false;
}
const freespaceKB = Number(deviceStatus.freespace) || 0;
const freespaceBytes = freespaceKB * 1024;
const payloadKB = Math.ceil(payloadSizeBytes / 1024);
const freespaceMB = Number(deviceStatus.freespace) || 0;
const freespaceBytes = freespaceMB * 1024 * 1024;
const payloadMB = (payloadSizeBytes / (1024 * 1024)).toFixed(2);
logger.info(
`Storage check: payload=${payloadKB}KB, available=${freespaceKB}KB`,
`Storage check: payload=${payloadMB}MB, available=${freespaceMB}MB`,
);
// Add 10% safety margin to avoid filling device completely
@@ -208,7 +208,7 @@ export class BeamBoxUploader {
if (freespaceBytes < requiredBytes) {
logger.error(
`Insufficient storage: need ${Math.ceil(requiredBytes / 1024)}KB (with 10% margin), have ${freespaceKB}KB`,
`Insufficient storage: need ${(requiredBytes / (1024 * 1024)).toFixed(2)}MB (with 10% margin), have ${freespaceMB}MB`,
);
return false;
}
+2 -2
View File
@@ -8,12 +8,12 @@ export interface DeviceStatus {
type: PacketType.DEVICE_STATUS;
/**
* Total storage capacity in kilobytes (KB)
* Total storage capacity in megabytes (MB)
*/
allspace: number;
/**
* Available free storage in kilobytes (KB)
* Available free storage in megabytes (MB)
*/
freespace: number;
+2 -2
View File
@@ -109,8 +109,8 @@ export enum PacketType {
* ```json
* {
* "type": 13,
* "allspace": 16384, // Total storage in KB
* "freespace": 13892, // Free storage in KB
* "allspace": 16384, // Total storage in MB
* "freespace": 13892, // Free storage in MB
* "devname": "", // Device name (usually empty)
* "size": "368,368", // Display resolution (width,height)
* "brand": 0 // Brand/model identifier