Skip to content

Commit

Permalink
Fix cached result retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
jackstanek committed Aug 12, 2016
1 parent 447ed3d commit b32c54d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 16 deletions.
17 changes: 9 additions & 8 deletions botbot/botbot.py
Expand Up @@ -70,17 +70,18 @@ def run_file_check(args, outpath):
all_file_checks = checks.ALLCHECKS + schecks.ALLSCHECKS
chkr.register(*all_file_checks)

# Set up default options
opt = {
'shared': args.shared if hasattr(args, 'shared') else True,
'link': args.follow_symlinks if hasattr(args, 'follow_symlinks') else False,
'verbose': args.verbose if hasattr(args, 'verbose') else False,
'force': args.force if hasattr(args, 'force') else False,
'me': args.me if hasattr(args, 'me') else False
# Get the options
opts = {
'shared': args.shared,
'link': args.follow_symlinks,
'verbose': args.verbose,
'cached': args.cached,
'force': args.force_recheck,
'me': args.me
}

# Run the checker!
chkr.check_all(path, **opt)
chkr.check_all(path, **opts)

def run_env_check(args, outpath):
# Import relevant environment checks
Expand Down
5 changes: 4 additions & 1 deletion botbot/checker.py
Expand Up @@ -124,7 +124,7 @@ def check_all(self, path, shared=False, link=False,
# Munge that path boys!
path = os.path.expanduser(path)
path = os.path.abspath(path)
self.path = path
self.path = py.path.local(path)

# If no cached tree exists, (or if we explicitly want to build
# a new one) build one if we need one
Expand All @@ -139,6 +139,9 @@ def check_all(self, path, shared=False, link=False,

self.db.store_file_problems(self.checked)

else:
self.checked = self.db.get_cached_results(self.path.strpath)

# Record stats and write the report. We out!
self.status['time'] = time.time() - starttime
self.reporter.write_report(fmt, shared)
Expand Down
19 changes: 13 additions & 6 deletions botbot/checkinfo.py
Expand Up @@ -16,13 +16,20 @@ def _is_important(path):
class CheckResult():
"""Holds the result of a check"""

def __init__(self, path, lastcheck=time.time(), probstr=None):
self.path = path
def __init__(self, path, lastcheck=time.time(), problems=None, md5sum=None):
if isinstance(path, str):
self.path = py.path.local(path)
elif isinstance(path, py.path.local):
self.path = path

self.lastcheck = lastcheck
if probstr:
self.decode_probstr(probstr)
else:
self.problems = set()

self.problems = set()
if problems:
if isinstance(problems, str):
self.decode_probstr(problems)

self.md5sum = md5sum

def add_problem(self, probstr):
"""Add a problem to this file"""
Expand Down
2 changes: 1 addition & 1 deletion botbot/sqlcache.py
Expand Up @@ -86,7 +86,7 @@ def get_cached_results(self, path, uid=None):

return [
ci.CheckResult(
dict(res)
**dict(res)
)
for res in cached
]
Expand Down

0 comments on commit b32c54d

Please sign in to comment.