Skip to content

Commit

Permalink
CI Cache test
Browse files Browse the repository at this point in the history
  • Loading branch information
AThousandShips committed Sep 7, 2024
1 parent 5675c76 commit 1b27e3b
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,7 @@ def show_progress(env):
# Has its own progress/tracking tool that clashes with ours
return

import atexit
import sys

from SCons.Script import AlwaysBuild, Command, Progress
Expand Down Expand Up @@ -920,7 +921,7 @@ def __init__(self, path=None, limit=1073741824, half_life=43200):
self.convert_size(limit), self.convert_size(self.get_size(path))
)
)
self.delete(self.file_list())
# self.delete(self.file_list())

def __call__(self, node, *args, **kw):
nonlocal node_count, node_count_max, node_count_interval, node_count_fname, show_progress
Expand All @@ -945,7 +946,7 @@ def delete(self, files):
screen.write("\rPurging %d %s from cache...\n" % (len(files), len(files) > 1 and "files" or "file"))
[os.remove(f) for f in files]

def file_list(self):
def file_list(self, limit_mult=1.0):
if self.path is None:
# Nothing to do
return []
Expand All @@ -968,7 +969,7 @@ def file_list(self):
sum, mark = 0, None
for i, x in enumerate(file_stat):
sum += x[1]
if sum > self.limit:
if sum > self.limit * limit_mult:
mark = i
break
if mark is None:
Expand Down Expand Up @@ -998,7 +999,7 @@ def progress_finish(target, source, env):
try:
with open(node_count_fname, "w", encoding="utf-8", newline="\n") as f:
f.write("%d\n" % node_count)
progressor.delete(progressor.file_list())
progressor.delete(progressor.file_list(1.1))
except Exception:
pass

Expand All @@ -1018,6 +1019,15 @@ def progress_finish(target, source, env):
progress_finish_command = Command("progress_finish", [], progress_finish)
AlwaysBuild(progress_finish_command)

def progress_finally():
nonlocal node_count, progressor
try:
progressor.delete(progressor.file_list())
except Exception:
pass

atexit.register(progress_finally)


def dump(env):
# Dumps latest build information for debugging purposes and external tools.
Expand Down

0 comments on commit 1b27e3b

Please sign in to comment.