Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions charon/pkgs/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@ def re_index(
"""Refresh the index.html for the specified folder in the bucket.
"""
s3_client = S3Client(aws_profile=aws_profile, dry_run=dry_run)
s3_folder = os.path.join(prefix, path)
real_prefix = prefix if prefix.strip() != "/" else ""
s3_folder = os.path.join(real_prefix, path)
if path.strip() == "" or path.strip() == "/":
s3_folder = prefix
items: List[str] = s3_client.list_folder_content(bucket, s3_folder)
Expand All @@ -285,11 +286,11 @@ def re_index(

if len(contents) >= 1:
real_contents = []
if prefix and prefix.strip() != "":
if real_prefix and real_prefix.strip() != "":
for c in contents:
if c.strip() != "":
if c.startswith(prefix):
real_c = remove_prefix(c, prefix)
if c.startswith(real_prefix):
real_c = remove_prefix(c, real_prefix)
real_c = remove_prefix(real_c, "/")
real_contents.append(real_c)
else:
Expand All @@ -302,9 +303,9 @@ def re_index(
index_path = os.path.join(path, "index.html")
if path == "/":
index_path = "index.html"
s3_client.simple_delete_file(index_path, (bucket, prefix))
s3_client.simple_delete_file(index_path, (bucket, real_prefix))
s3_client.simple_upload_file(
index_path, index_content, (bucket, prefix),
index_path, index_content, (bucket, real_prefix),
"text/html", digest_content(index_content)
)
else:
Expand Down
2 changes: 1 addition & 1 deletion charon/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ def simple_upload_file(
Metadata=f_meta,
ContentType=content_type
)
logger.debug('Uploaded %s to bucket %s', file_path, bucket)
logger.debug('Uploaded %s to bucket %s', path_key, bucket)
except (ClientError, HTTPClientError) as e:
logger.error(
"ERROR: file %s not uploaded to bucket %s due to error: %s ",
Expand Down