mirror of
https://github.com/FAUSheppy/homelab_gamevault
synced 2025-12-05 22:51:34 +01:00
feat: cache size display
This commit is contained in:
15
cache_utils.py
Normal file
15
cache_utils.py
Normal file
@@ -0,0 +1,15 @@
|
||||
import os
|
||||
|
||||
def get_cache_size(directory="./cache"):
|
||||
|
||||
'''check directory sizes and sum up'''
|
||||
print(directory)
|
||||
total_size = 0
|
||||
for dirpath, dirnames, filenames in os.walk(directory):
|
||||
for filename in filenames:
|
||||
filepath = os.path.join(dirpath, filename)
|
||||
total_size += os.path.getsize(filepath)
|
||||
|
||||
# Convert bytes to gigabytes #
|
||||
total_size_gb = total_size / (1024 * 1024 * 1024)
|
||||
return total_size_gb
|
||||
11
client.py
11
client.py
@@ -4,6 +4,10 @@ import data_backend
|
||||
import client_details
|
||||
import pgwrapper
|
||||
import sys
|
||||
import json
|
||||
import os
|
||||
import cache_utils
|
||||
import imagetools
|
||||
|
||||
customtkinter.set_appearance_mode("dark")
|
||||
customtkinter.set_default_color_theme("blue")
|
||||
@@ -144,9 +148,16 @@ def load_main():
|
||||
app.title("Lan Vault: Overview")
|
||||
|
||||
# create tiles from meta files #
|
||||
cache_dir_size = 0
|
||||
for software in db.find_all_metadata():
|
||||
create_main_window_tile(software)
|
||||
|
||||
# retrieve cache dir from any software #
|
||||
if not cache_dir_size:
|
||||
cache_dir_size = cache_utils.get_cache_size()
|
||||
label = customtkinter.CTkLabel(app, text="Cache Size: {:.2f} GB".format(cache_dir_size))
|
||||
label.grid(row=0, column=0)
|
||||
|
||||
# set update listener & update positions #
|
||||
update_button_positions()
|
||||
app.bind("<Configure>", update_button_positions)
|
||||
|
||||
Reference in New Issue
Block a user