diff options
author | Andy Doan <andy.doan@linaro.org> | 2015-05-15 14:38:46 -0500 |
---|---|---|
committer | Andy Doan <andy.doan@linaro.org> | 2015-05-18 10:02:58 -0500 |
commit | 88a304d85924a7a661d7f21053efdbdd09233d83 (patch) | |
tree | 700bc5d67c26061e4114ebc853b68f2bae674738 /license_protected_downloads/common.py | |
parent | 290e0b9440d930283a5ef222f2c421ff97a23c03 (diff) |
only show license column when have files in the directory
This change helps 2 things:
1) people sometimes find it confusing why we don't show license values
2) performance - we have to recurse into each sub-directory when doing a
directory listing, to find license info.
This helps #1 by only showing the column if there's a file with
licensing. #2 is less important now, but will likely be important in the
future if we move away from using local disk for storing artifacts.
Change-Id: I31d4e4a34a8f289163f1ba3fa9297a115a7579b9
Diffstat (limited to 'license_protected_downloads/common.py')
-rw-r--r-- | license_protected_downloads/common.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/license_protected_downloads/common.py b/license_protected_downloads/common.py index 499a34e..df3af29 100644 --- a/license_protected_downloads/common.py +++ b/license_protected_downloads/common.py @@ -243,8 +243,18 @@ def dir_list(url, path, human_readable=True): if os.path.isdir(file_name): target_type = "folder" + license_digest_list = [] else: target_type = mimetypes.guess_type(name)[0] + pathname = os.path.join(path, name) + try: + license_digest_list = is_protected(pathname) + except Exception as e: + print("Invalid BUILD-INFO.txt for %s: %s" % (pathname, repr(e))) + traceback.print_exc() + license_digest_list = "INVALID" + license_list = models.License.objects.all_with_hashes( + license_digest_list) if os.path.exists(file_name): size = os.path.getsize(file_name) @@ -272,15 +282,6 @@ def dir_list(url, path, human_readable=True): size = _sizeof_fmt(size) - pathname = os.path.join(path, name) - try: - license_digest_list = is_protected(pathname) - except Exception as e: - print("Invalid BUILD-INFO.txt for %s: %s" % (pathname, repr(e))) - traceback.print_exc() - license_digest_list = "INVALID" - license_list = models.License.objects.all_with_hashes( - license_digest_list) listing.append({'name': name, 'size': size, 'type': target_type, |