mirror of
https://github.com/YuzuZensai/beamboxctl.git
synced 2026-07-21 20:42:19 +00:00
🐛 fix: incorrect storage size
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user