Skip to content

Commit 1cb2204

Browse files
committed
add deleting old files from temp dir
1 parent adaf704 commit 1cb2204

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

mytoncore/mytoncore.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1495,10 +1495,26 @@ def ElectionEntry(self, args=None):
14951495

14961496
# Save vars to json file
14971497
self.SaveElectionVarsToJsonFile(wallet=wallet, account=account, stake=stake, maxFactor=maxFactor, fullElectorAddr=fullElectorAddr, startWorkTime=startWorkTime, validatorsElectedFor=validatorsElectedFor, endWorkTime=endWorkTime, validatorKey=validatorKey, validatorPubkey_b64=validatorPubkey_b64, adnlAddr=adnl_addr, var1=var1, validatorSignature=validatorSignature, validatorPubkey=validatorPubkey)
1498-
14991498
self.local.add_log("ElectionEntry completed. Start work time: " + str(startWorkTime))
1499+
1500+
self.clear_tmp()
1501+
15001502
#end define
15011503

1504+
def clear_tmp(self):
1505+
start = time.time()
1506+
count = 0
1507+
dir = self.tempDir
1508+
for f in os.listdir(dir):
1509+
ts = f.split('_')[0]
1510+
if ts.isdigit():
1511+
ts = int(ts)
1512+
week = 60 * 60 * 24 * 7
1513+
if ts < time.time() - week:
1514+
count += 1
1515+
os.remove(os.path.join(dir, f))
1516+
self.local.add_log(f"Removed {count} old files from tmp dir for {int(time.time() - start)} seconds", "info")
1517+
15021518
def GetValidatorKeyByTime(self, startWorkTime, endWorkTime):
15031519
self.local.add_log("start GetValidatorKeyByTime function", "debug")
15041520
# Check temp key

0 commit comments

Comments
 (0)