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,
|
||||
verbose,
|
||||
}) => {
|
||||
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 allspaceKiB = typeof status?.allspace === "number" ? status.allspace : 0;
|
||||
const freespaceKiB = typeof status?.freespace === "number" ? status.freespace : 0;
|
||||
const allspace = allspaceKiB * 1024;
|
||||
const freespace = freespaceKiB * 1024;
|
||||
const usedSpace = allspace - freespace;
|
||||
const freePercentage =
|
||||
allspace > 0 ? Math.round((freespace / allspace) * 100) : 0;
|
||||
|
||||
@@ -183,7 +183,7 @@ export class BeamBoxUploader {
|
||||
// Check device storage before upload
|
||||
if (!this.checkStorageCapacity(fullData.length)) {
|
||||
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.`,
|
||||
);
|
||||
}
|
||||
@@ -221,20 +221,19 @@ export class BeamBoxUploader {
|
||||
return false;
|
||||
}
|
||||
|
||||
const freespaceMB = Number(deviceStatus.freespace) || 0;
|
||||
const freespaceBytes = freespaceMB * 1024 * 1024;
|
||||
const payloadMB = (payloadSizeBytes / (1024 * 1024)).toFixed(2);
|
||||
const freespaceKiB = Number(deviceStatus.freespace) || 0;
|
||||
const freespaceBytes = freespaceKiB * 1024;
|
||||
const payloadKiB = (payloadSizeBytes / 1024).toFixed(2);
|
||||
|
||||
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);
|
||||
|
||||
if (freespaceBytes < requiredBytes) {
|
||||
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;
|
||||
}
|
||||
@@ -434,7 +433,7 @@ export class BeamBoxUploader {
|
||||
|
||||
if (!this.checkStorageCapacity(fullData.length)) {
|
||||
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.`,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -7,14 +7,10 @@ export interface DeviceStatus {
|
||||
/** Packet type identifier (always 13 for DEVICE_STATUS) */
|
||||
type: PacketType.DEVICE_STATUS;
|
||||
|
||||
/**
|
||||
* Total storage capacity in megabytes (MB)
|
||||
*/
|
||||
/** Total storage capacity in KiB */
|
||||
allspace: number;
|
||||
|
||||
/**
|
||||
* Available free storage in megabytes (MB)
|
||||
*/
|
||||
/** Available free storage in KiB */
|
||||
freespace: number;
|
||||
|
||||
/**
|
||||
|
||||
@@ -109,8 +109,8 @@ export enum PacketType {
|
||||
* ```json
|
||||
* {
|
||||
* "type": 13,
|
||||
* "allspace": 16384, // Total storage in MB
|
||||
* "freespace": 13892, // Free storage in MB
|
||||
* "allspace": 16384, // Total storage in KiB
|
||||
* "freespace": 13892, // Free storage in KiB
|
||||
* "devname": "", // Device name (usually empty)
|
||||
* "size": "368,368", // Display resolution (width,height)
|
||||
* "brand": 0 // Brand/model identifier
|
||||
|
||||
Reference in New Issue
Block a user