make new files go brrrr!

This commit is contained in:
Bogdan 2023-12-22 01:20:14 +01:00
parent 9229d463cb
commit 6654527ffc
2 changed files with 17 additions and 3 deletions

View File

@ -41,7 +41,7 @@ class Index:
self.context.log(stat, os.path.join(self.path, name))
# calc new hashes for this index
def update(self):
def update(self, update):
for name in self.files:
if self.should_ignore(name):
self._log(Status.SKIP, name)
@ -57,7 +57,12 @@ class Index:
self.old[name] = {"mod": old["mod"], "a": a, "h": old["md5"]}
elif "a" in old:
a = old["a"]
self.new[name] = self._calc_file(name, a)
self.new[name] = self._calc_file(name, a)
else:
if update:
self.new[name] = self._calc_file(name, a)
else:
self.new[name] = self._list_file(name, a)
# check/update the index (old vs new)
def check_fix(self, force):
@ -95,6 +100,15 @@ class Index:
self._log(Status.WARN_OLD, name)
self._setmod()
def _list_file(self, name, a):
path = os.path.join(self.path, name)
self.context.hit(cfiles=1)
return {
"mod": None,
"a": a,
"h": None,
}
def _calc_file(self, name, a):
path = os.path.join(self.path, name)
info = os.stat(path)

View File

@ -37,7 +37,7 @@ class IndexThread:
index.load()
# calc the new hashes
index.update()
index.update(self.update)
# compare
index.check_fix(self.context.force)