mirror of
https://github.com/abraunegg/onedrive
synced 2024-06-26 17:30:25 +02:00
Update FR #2359
Update --display-quota output to: Deleted: 8.19 GB (8793627814 bytes) Remaining: 25580.69 GB (27467060611614 bytes) State: normal Total: 25600.00 GB (27487790694400 bytes) Used: 11.12 GB (11936454972 bytes)
This commit is contained in:
parent
8979bf7437
commit
16595efbdb
22
src/sync.d
22
src/sync.d
|
@ -2406,7 +2406,7 @@ class SyncEngine {
|
|||
// What do we display here for space remaining
|
||||
if (appConfig.remainingFreeSpace > 0) {
|
||||
// Display the actual value
|
||||
log.vlog("Remaining Free Space: ", (appConfig.remainingFreeSpace/1024) , " KB");
|
||||
log.vlog("Remaining Free Space: ", byteToGibiByte(appConfig.remainingFreeSpace) , " GB (", appConfig.remainingFreeSpace, " bytes)");
|
||||
} else {
|
||||
// zero or non-zero value or restricted
|
||||
if (!appConfig.quotaRestricted){
|
||||
|
@ -7023,6 +7023,8 @@ class SyncEngine {
|
|||
// Query OneDrive for the quota details
|
||||
void queryOneDriveForQuotaDetails() {
|
||||
// This function is similar to getRemainingFreeSpace() but is different in data being analysed and output method
|
||||
|
||||
|
||||
|
||||
JSONValue currentDriveQuota;
|
||||
string driveId;
|
||||
|
@ -7065,11 +7067,11 @@ class SyncEngine {
|
|||
|
||||
// Update values
|
||||
if ("deleted" in currentDriveQuota["quota"]) {
|
||||
deletedValue = to!string(currentDriveQuota["quota"]["deleted"].integer);
|
||||
deletedValue = byteToGibiByte(currentDriveQuota["quota"]["deleted"].integer);
|
||||
}
|
||||
|
||||
if ("remaining" in currentDriveQuota["quota"]) {
|
||||
remainingValue = to!string(currentDriveQuota["quota"]["remaining"].integer);
|
||||
remainingValue = byteToGibiByte(currentDriveQuota["quota"]["remaining"].integer);
|
||||
}
|
||||
|
||||
if ("state" in currentDriveQuota["quota"]) {
|
||||
|
@ -7077,23 +7079,21 @@ class SyncEngine {
|
|||
}
|
||||
|
||||
if ("total" in currentDriveQuota["quota"]) {
|
||||
totalValue = to!string(currentDriveQuota["quota"]["total"].integer);
|
||||
totalValue = byteToGibiByte(currentDriveQuota["quota"]["total"].integer);
|
||||
}
|
||||
|
||||
if ("used" in currentDriveQuota["quota"]) {
|
||||
usedValue = to!string(currentDriveQuota["quota"]["used"].integer);
|
||||
usedValue = byteToGibiByte(currentDriveQuota["quota"]["used"].integer);
|
||||
}
|
||||
|
||||
writeln("Microsoft OneDrive quota information as reported for this Drive ID: ", driveId);
|
||||
writeln();
|
||||
writeln("Deleted: ", deletedValue);
|
||||
writeln("Remaining: ", remainingValue);
|
||||
writeln("Deleted: ", deletedValue, " GB (", currentDriveQuota["quota"]["deleted"].integer, " bytes)");
|
||||
writeln("Remaining: ", remainingValue, " GB (", currentDriveQuota["quota"]["remaining"].integer, " bytes)");
|
||||
writeln("State: ", stateValue);
|
||||
writeln("Total: ", totalValue);
|
||||
writeln("Used: ", usedValue);
|
||||
writeln("Total: ", totalValue, " GB (", currentDriveQuota["quota"]["total"].integer, " bytes)");
|
||||
writeln("Used: ", usedValue, " GB (", currentDriveQuota["quota"]["used"].integer, " bytes)");
|
||||
writeln();
|
||||
writeln("The numeric values above are expressed in bytes");
|
||||
|
||||
} else {
|
||||
writeln("Microsoft OneDrive quota information is being restricted for this Drive ID: ", driveId);
|
||||
}
|
||||
|
|
|
@ -21,6 +21,8 @@ import std.json;
|
|||
import std.traits;
|
||||
import core.stdc.stdlib;
|
||||
import core.thread;
|
||||
import std.math;
|
||||
import std.format;
|
||||
|
||||
// What other modules that we have created do we need to import?
|
||||
import log;
|
||||
|
@ -790,4 +792,11 @@ bool hasETag(const ref JSONValue item) {
|
|||
|
||||
bool hasSharedElement(const ref JSONValue item) {
|
||||
return ("eTag" in item) != null;
|
||||
}
|
||||
|
||||
// Convert bytes to GB
|
||||
string byteToGibiByte(ulong bytes) {
|
||||
double gib = bytes / pow(1024.0,3);
|
||||
double roundedGib = round(gib * 100) / 100;
|
||||
return to!string(format("%.2f", roundedGib)); // Format to ensure two decimal places
|
||||
}
|
Loading…
Reference in a new issue