mirror of
https://github.com/YuzuZensai/beamboxctl.git
synced 2026-07-21 20:42:19 +00:00
🐛 fix: incorrect storage size (oops)
This commit is contained in:
@@ -48,11 +48,10 @@ export const Status: React.FC<StatusProps> = ({
|
|||||||
notifications,
|
notifications,
|
||||||
verbose,
|
verbose,
|
||||||
}) => {
|
}) => {
|
||||||
const allspaceMB = typeof status?.allspace === "number" ? status.allspace : 0;
|
const allspaceKiB = typeof status?.allspace === "number" ? status.allspace : 0;
|
||||||
const freespaceMB =
|
const freespaceKiB = typeof status?.freespace === "number" ? status.freespace : 0;
|
||||||
typeof status?.freespace === "number" ? status.freespace : 0;
|
const allspace = allspaceKiB * 1024;
|
||||||
const allspace = allspaceMB * 1024 * 1024;
|
const freespace = freespaceKiB * 1024;
|
||||||
const freespace = freespaceMB * 1024 * 1024;
|
|
||||||
const usedSpace = allspace - freespace;
|
const usedSpace = allspace - freespace;
|
||||||
const freePercentage =
|
const freePercentage =
|
||||||
allspace > 0 ? Math.round((freespace / allspace) * 100) : 0;
|
allspace > 0 ? Math.round((freespace / allspace) * 100) : 0;
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ export class BeamBoxUploader {
|
|||||||
// Check device storage before upload
|
// Check device storage before upload
|
||||||
if (!this.checkStorageCapacity(fullData.length)) {
|
if (!this.checkStorageCapacity(fullData.length)) {
|
||||||
throw new UploadError(
|
throw new UploadError(
|
||||||
`Insufficient device storage. Image requires ${Math.ceil(fullData.length / 1024)}KB. ` +
|
`Insufficient device storage. Image requires ${Math.ceil(fullData.length / 1024)}KiB. ` +
|
||||||
`Try reducing image size or quality.`,
|
`Try reducing image size or quality.`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -221,20 +221,19 @@ export class BeamBoxUploader {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const freespaceMB = Number(deviceStatus.freespace) || 0;
|
const freespaceKiB = Number(deviceStatus.freespace) || 0;
|
||||||
const freespaceBytes = freespaceMB * 1024 * 1024;
|
const freespaceBytes = freespaceKiB * 1024;
|
||||||
const payloadMB = (payloadSizeBytes / (1024 * 1024)).toFixed(2);
|
const payloadKiB = (payloadSizeBytes / 1024).toFixed(2);
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
`Storage check: payload=${payloadMB}MB, available=${freespaceMB}MB`,
|
`Storage check: payload=${payloadKiB}KiB, available=${freespaceKiB}KiB`,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Add 10% safety margin to avoid filling device completely
|
|
||||||
const requiredBytes = Math.ceil(payloadSizeBytes * 1.1);
|
const requiredBytes = Math.ceil(payloadSizeBytes * 1.1);
|
||||||
|
|
||||||
if (freespaceBytes < requiredBytes) {
|
if (freespaceBytes < requiredBytes) {
|
||||||
logger.error(
|
logger.error(
|
||||||
`Insufficient storage: need ${(requiredBytes / (1024 * 1024)).toFixed(2)}MB (with 10% margin), have ${freespaceMB}MB`,
|
`Insufficient storage: need ${(requiredBytes / 1024).toFixed(2)}KiB (with 10% margin), have ${freespaceKiB}KiB`,
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -434,7 +433,7 @@ export class BeamBoxUploader {
|
|||||||
|
|
||||||
if (!this.checkStorageCapacity(fullData.length)) {
|
if (!this.checkStorageCapacity(fullData.length)) {
|
||||||
throw new UploadError(
|
throw new UploadError(
|
||||||
`Insufficient device storage. Animation requires ${Math.ceil(fullData.length / 1024)}KB. ` +
|
`Insufficient device storage. Animation requires ${Math.ceil(fullData.length / 1024)}KiB. ` +
|
||||||
`Try reducing frames or image quality.`,
|
`Try reducing frames or image quality.`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,14 +7,10 @@ export interface DeviceStatus {
|
|||||||
/** Packet type identifier (always 13 for DEVICE_STATUS) */
|
/** Packet type identifier (always 13 for DEVICE_STATUS) */
|
||||||
type: PacketType.DEVICE_STATUS;
|
type: PacketType.DEVICE_STATUS;
|
||||||
|
|
||||||
/**
|
/** Total storage capacity in KiB */
|
||||||
* Total storage capacity in megabytes (MB)
|
|
||||||
*/
|
|
||||||
allspace: number;
|
allspace: number;
|
||||||
|
|
||||||
/**
|
/** Available free storage in KiB */
|
||||||
* Available free storage in megabytes (MB)
|
|
||||||
*/
|
|
||||||
freespace: number;
|
freespace: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -109,8 +109,8 @@ export enum PacketType {
|
|||||||
* ```json
|
* ```json
|
||||||
* {
|
* {
|
||||||
* "type": 13,
|
* "type": 13,
|
||||||
* "allspace": 16384, // Total storage in MB
|
* "allspace": 16384, // Total storage in KiB
|
||||||
* "freespace": 13892, // Free storage in MB
|
* "freespace": 13892, // Free storage in KiB
|
||||||
* "devname": "", // Device name (usually empty)
|
* "devname": "", // Device name (usually empty)
|
||||||
* "size": "368,368", // Display resolution (width,height)
|
* "size": "368,368", // Display resolution (width,height)
|
||||||
* "brand": 0 // Brand/model identifier
|
* "brand": 0 // Brand/model identifier
|
||||||
|
|||||||
Reference in New Issue
Block a user