未验证 提交 53c55f7d 编写于 作者: A aaron ai 提交者: GitHub

[ISSUE #3245] Use df algorithm to calculate the disk used ratio

上级 36041006
...@@ -218,10 +218,15 @@ public class UtilAll { ...@@ -218,10 +218,15 @@ public class UtilAll {
long totalSpace = file.getTotalSpace(); long totalSpace = file.getTotalSpace();
if (totalSpace > 0) { if (totalSpace > 0) {
long freeSpace = file.getFreeSpace(); long usedSpace = totalSpace - file.getFreeSpace();
long usedSpace = totalSpace - freeSpace; long usableSpace = file.getUsableSpace();
long entireSpace = usedSpace + usableSpace;
return usedSpace / (double) totalSpace; long roundNum = 0;
if (usedSpace * 100 % entireSpace != 0) {
roundNum = 1;
}
long result = usedSpace * 100 / entireSpace + roundNum;
return result / 100.0;
} }
} catch (Exception e) { } catch (Exception e) {
log.error("Error when measuring disk space usage, got exception: :", e); log.error("Error when measuring disk space usage, got exception: :", e);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册