summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--license_protected_downloads/artifact/s3.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/license_protected_downloads/artifact/s3.py b/license_protected_downloads/artifact/s3.py
index c5fc109..ef1d57c 100644
--- a/license_protected_downloads/artifact/s3.py
+++ b/license_protected_downloads/artifact/s3.py
@@ -29,8 +29,9 @@ class S3Artifact(Artifact):
return cls.bucket
def __init__(self, bucket, item, parent, human_readable):
- base = '/' + os.path.dirname(item.name)
- base = base.replace(settings.S3_PREFIX_PATH, '')
+ base = item.name.replace(settings.S3_PREFIX_PATH, '')
+ if base:
+ base = '/' + os.path.dirname(base)
if hasattr(item, 'size'):
file_name = os.path.basename(item.name)
@@ -42,8 +43,11 @@ class S3Artifact(Artifact):
else:
self.mtype = 'folder'
self.children = []
- base = os.path.dirname(base)
- file_name = os.path.basename(item.name[:-1])
+ if base:
+ base = os.path.dirname(base)
+ file_name = os.path.basename(item.name[:-1])
+ else:
+ file_name = ''
item.size = 0
item.last_modified = '-'
self.bucket = bucket