Update info_api.py
added a way to disable getDiskUsageInfo
This commit is contained in:
parent
5596f53744
commit
187869c21d
1 changed files with 16 additions and 15 deletions
|
@ -10,13 +10,14 @@ _cache_result = None # type: Optional[int]
|
|||
|
||||
|
||||
def _get_disk_usage() -> int:
|
||||
total_size = 0
|
||||
if config.config["data_dir_get_usage"] == 1:
|
||||
global _cache_time, _cache_result
|
||||
threshold = timedelta(hours=48)
|
||||
now = datetime.utcnow()
|
||||
if _cache_time and _cache_time > now - threshold:
|
||||
assert _cache_result is not None
|
||||
return _cache_result
|
||||
total_size = 0
|
||||
for dir_path, _, file_names in os.walk(config.config["data_dir"]):
|
||||
for file_name in file_names:
|
||||
file_path = os.path.join(dir_path, file_name)
|
||||
|
|
Loading…
Reference in a new issue