mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
Compare commits
5 Commits
master
...
fb0b4b0223
Author | SHA1 | Date | |
---|---|---|---|
fb0b4b0223 | |||
19aa5acd62 | |||
d34d9a972d | |||
5629ffa332 | |||
187869c21d |
@ -177,3 +177,9 @@ privileges:
|
|||||||
## usage: schema://user:password@host:port/database_name
|
## usage: schema://user:password@host:port/database_name
|
||||||
## example: postgres://szuru:dog@localhost:5432/szuru_test
|
## example: postgres://szuru:dog@localhost:5432/szuru_test
|
||||||
#database:
|
#database:
|
||||||
|
|
||||||
|
|
||||||
|
## get the data dir usage
|
||||||
|
## false disabled
|
||||||
|
## true enabled ( default )
|
||||||
|
data_dir_get_usage: true
|
||||||
|
@ -10,22 +10,23 @@ _cache_result = None # type: Optional[int]
|
|||||||
|
|
||||||
|
|
||||||
def _get_disk_usage() -> int:
|
def _get_disk_usage() -> int:
|
||||||
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
|
total_size = 0
|
||||||
for dir_path, _, file_names in os.walk(config.config["data_dir"]):
|
if config.config["data_dir_get_usage"]:
|
||||||
for file_name in file_names:
|
global _cache_time, _cache_result
|
||||||
file_path = os.path.join(dir_path, file_name)
|
threshold = timedelta(hours=48)
|
||||||
try:
|
now = datetime.utcnow()
|
||||||
total_size += os.path.getsize(file_path)
|
if _cache_time and _cache_time > now - threshold:
|
||||||
except FileNotFoundError:
|
assert _cache_result is not None
|
||||||
pass
|
return _cache_result
|
||||||
_cache_time = now
|
for dir_path, _, file_names in os.walk(config.config["data_dir"]):
|
||||||
_cache_result = total_size
|
for file_name in file_names:
|
||||||
|
file_path = os.path.join(dir_path, file_name)
|
||||||
|
try:
|
||||||
|
total_size += os.path.getsize(file_path)
|
||||||
|
except FileNotFoundError:
|
||||||
|
pass
|
||||||
|
_cache_time = now
|
||||||
|
_cache_result = total_size
|
||||||
return total_size
|
return total_size
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user