From 251c1e53fc41a54e71b0411e3c75832ed90ba30b Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Mon, 29 Apr 2019 10:27:52 +0800 Subject: [PATCH] simple doClean Flag --- Common.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Common.py b/Common.py index ee5f0d0..fd03ea9 100644 --- a/Common.py +++ b/Common.py @@ -15,6 +15,7 @@ config = json.load(_config_fp) _config_fp.close() bypy = ByPy() doCleanTime = datetime.now() +_clean_flag = None network = { "currentTime": datetime.now(), @@ -47,7 +48,7 @@ def getTimeDelta(a, b): def _doClean(_force=False): - global doCleanTime + global doCleanTime, _clean_flag _disk = psutil.disk_usage(".") if (_disk.percent > config["max"] and getTimeDelta(datetime.now(), doCleanTime) > 7200) or _force: doCleanTime = datetime.now() @@ -57,6 +58,7 @@ def _doClean(_force=False): break doCleanTime = datetime.now() if (datetime.now() - datetime.utcfromtimestamp(os.path.getmtime(_i))).days > config["exp"]: + _clean_flag = True if config["dow"] == "bypy": _res = bypy.upload(_i) if _res == 0: @@ -66,9 +68,13 @@ def _doClean(_force=False): else: break doCleanTime = datetime.now() + _clean_flag = False def doClean(_force=False): + if _clean_flag: + appendError("doClean request on cleaning, will ignore it") + return p = threading.Thread(target=_doClean, args=(_force,)) p.setDaemon(True) p.start()