Skip to content

Commit

Permalink
File sizes were not being added
Browse files Browse the repository at this point in the history
  • Loading branch information
hexylena committed Feb 27, 2018
1 parent 60561c2 commit 71c79fd
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions scripts/grt/export.py
Expand Up @@ -78,7 +78,7 @@ def __init__(self, sanitization_config, model, sa_session):
self.sanitization_config['tool_params'] = {}

def blacklisted_tree(self, path):
if path.lstrip('.') in self.sanitization_config['tool_params'][self.tool_id]:
if self.tool_id in self.sanitization_config['tool_params'] and path.lstrip('.') in self.sanitization_config['tool_params'][self.tool_id]:
return True
return False

Expand All @@ -88,17 +88,12 @@ def sanitize_data(self, tool_id, key, value):
return 'null'
# Thus, all tools below here are not blacklisted at the top level.

# If it isn't in tool_params, there are no keys being sanitized for
# this tool so we can return quickly without parsing.
if tool_id not in self.sanitization_config['tool_params']:
return value

# If the key is listed precisely (not a sub-tree), we can also return slightly more quickly.
if key in self.sanitization_config['tool_params'][tool_id]:
if tool_id in self.sanitization_config['tool_params'] and key in self.sanitization_config['tool_params'][tool_id]:
return 'null'

# If the key isn't a prefix for any of the keys being sanitized, then this is safe.
if not any(san_key.startswith(key) for san_key in self.sanitization_config['tool_params'][tool_id]):
if tool_id in self.sanitization_config['tool_params'] and not any(san_key.startswith(key) for san_key in self.sanitization_config['tool_params'][tool_id]):
return value

# Slow path.
Expand Down Expand Up @@ -126,7 +121,8 @@ def _file_dict(self, data):
self.filesize_cache[data['id']] = data
return data
else:
raise Exception("Cannot handle {src} yet".format(data))
logging.warning("Cannot handle {src} yet".format(data))
return data

def _sanitize_dict(self, unsanitized_dict, path=""):
# if it is a file dictionary, handle specially.
Expand Down

0 comments on commit 71c79fd

Please sign in to comment.