Skip to content

Commit bb3e5d1

Browse files
Kevin Turnerpsychedelicious
authored andcommitted
feat(Model Manager): refuse to download a file when there's insufficient space
1 parent e62d3f0 commit bb3e5d1

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

invokeai/app/services/download/download_default.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import traceback
99
from pathlib import Path
1010
from queue import Empty, PriorityQueue
11+
from shutil import disk_usage
1112
from typing import TYPE_CHECKING, Any, Dict, List, Literal, Optional, Set
1213

1314
import requests
@@ -335,6 +336,14 @@ def _do_download(self, job: DownloadJob) -> None:
335336

336337
assert job.download_path
337338

339+
free_space = disk_usage(job.download_path.parent).free
340+
GB = 2**30
341+
self._logger.debug(f"Download is {job.total_bytes / GB:.2f} GB of {free_space / GB:.2f} GB free.")
342+
if free_space < job.total_bytes:
343+
raise RuntimeError(
344+
f"Free disk space {free_space / GB:.2f} GB is not enough for download of {job.total_bytes / GB:.2f} GB."
345+
)
346+
338347
# Don't clobber an existing file. See commit 82c2c85202f88c6d24ff84710f297cfc6ae174af
339348
# for code that instead resumes an interrupted download.
340349
if job.download_path.exists():

0 commit comments

Comments
 (0)