-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy path01-add-oem-disk-usage-support.patch
More file actions
48 lines (45 loc) · 1.82 KB
/
01-add-oem-disk-usage-support.patch
File metadata and controls
48 lines (45 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
--- a/moonraker/components/file_manager/file_manager.py 2026-02-06 19:12:24.179575409 +0100
+++ b/moonraker/components/file_manager/file_manager.py 2026-02-06 19:13:16.448036223 +0100
@@ -825,10 +825,12 @@
}
flist['disk_usage'] = disk_usage
else:
+ free, total = self.get_user_space("/oem", 0)
+ used = total - free
disk_usage = {
- 'free': 0,
- 'total': OEM_SPACE,
- 'used': OEM_SPACE
+ 'free': free,
+ 'total': total,
+ 'used': used
}
flist['disk_usage'] = disk_usage
flist['root_info'] = {
@@ -876,15 +878,16 @@
TMP_GCODE_DIR,
f"moonraker.upload-{loop_time}.mru")
- def get_user_space(self) -> Any:
+ def get_user_space(self, dir: str = USER_DATA_PATH, reserved: int = RESERVED_USER_SPACE) -> Any:
"""Get the total & free space in MiB for the given path."""
try:
- statvfs = os.statvfs(USER_DATA_PATH)
+ statvfs = os.statvfs(dir)
free_space = statvfs.f_frsize * statvfs.f_bavail
total_space = statvfs.f_frsize * statvfs.f_blocks
- total_space -= RESERVED_USER_SPACE
- free_space -= RESERVED_USER_SPACE
+ total_space -= reserved
+ free_space -= reserved
+
if total_space < 0:
total_space = 0
free_space = 0
@@ -892,7 +895,7 @@
free_space = 0
return free_space, total_space
except Exception as e:
- logging.error(f"Failed to get free space for {USER_DATA_PATH}: {e}")
+ logging.error(f"Failed to get free space for {dir}: {e}")
return 0, 0
def check_gcodes_space(self, required_space: int) -> bool: