mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-03 17:39:42 +02:00
check for free disk space at startup
resolve merge
This commit is contained in:
@@ -21,6 +21,25 @@ def get_free_space_mb(dirname):
|
||||
st = os.statvfs(dirname)
|
||||
return st.f_bavail * st.f_frsize
|
||||
|
||||
def check_space():
|
||||
while not state.shutdown_event.is_set():
|
||||
for magnet_uri, magnetdl in list(state.active_downloads.items()):
|
||||
try:
|
||||
status = magnetdl.status()
|
||||
except RuntimeError:
|
||||
continue
|
||||
|
||||
if status.state == lt.torrent_status.downloading:
|
||||
free_space = get_free_space_mb(state.download_path)
|
||||
total_size = status.total_wanted
|
||||
|
||||
if free_space < total_size:
|
||||
consoleLog(f"Not enough free space to continue downloading: {status.name}")
|
||||
magnetdl.pause()
|
||||
break
|
||||
|
||||
time.sleep(5)
|
||||
|
||||
def init_session():
|
||||
if state.dl_session is not None:
|
||||
return
|
||||
|
||||
+3
-1
@@ -3,6 +3,7 @@ from core.utils.logging.loghandler import split_data, check_completed, check_dow
|
||||
from core.network.interface import list_interfaces, init_interfaces
|
||||
from core.utils.logging.logs import get_download_logs
|
||||
from core.utils.logging.logs import set_main_window
|
||||
from core.network.libtorrent_int import check_space
|
||||
from core.utils.general.shutdown import closehelper
|
||||
from core.utils.general.wrappers import run_thread
|
||||
from core.utils.general.shutdown import force_exit
|
||||
@@ -59,6 +60,7 @@ def main():
|
||||
# Start background non-daemon threads
|
||||
run_thread(threading.Thread(target=check_completed, args=(downloads, state.autoresume)))
|
||||
run_thread(threading.Thread(target=check_downloads, args=(downloads,)))
|
||||
run_thread(threading.Thread(target=check_space, args=()))
|
||||
# Finish counting startup time
|
||||
elapsed = time.perf_counter() - start_time
|
||||
consoleLog(f"Initialization completed in {elapsed:.2f}s. Launching GUI")
|
||||
@@ -66,4 +68,4 @@ def main():
|
||||
run_gui()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user