Skip to content

Commit

Permalink
Merge pull request #10 from spock/validate-go-brrrr
Browse files Browse the repository at this point in the history
make new files validation go brrrr!
  • Loading branch information
laktak authored Dec 22, 2023
2 parents 1075570 + 6654527 commit 360167c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
18 changes: 16 additions & 2 deletions chkbit/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def _log(self, stat: Status, name: str):
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)
Expand All @@ -57,7 +57,12 @@ def update(self):
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):
Expand Down Expand Up @@ -95,6 +100,15 @@ def check_fix(self, force):
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)
Expand Down
2 changes: 1 addition & 1 deletion chkbit/index_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def _process_root(self, parent):
index.load()

# calc the new hashes
index.update()
index.update(self.update)

# compare
index.check_fix(self.context.force)
Expand Down

0 comments on commit 360167c

Please sign in to comment.