Fix compatibility with old .file-hashes files

boto3 uploads /some/key to bucket//some/key, leaving part of the path
with "//", or a folder without a name. To remedy this, I had lstrip'd
the / from the key before upload. I didn't think about the fact that
boto2 works fine with this, and the old .file-hashes file would have the
keys with the prefixing forward slash. This solves that
This commit is contained in:
Franklyn Tackitt
2015-08-20 16:33:19 -07:00
parent 34cc79dcae
commit e39fc3e3ed
+6 -5
View File
@@ -128,20 +128,21 @@ def _write_files(s3, app, static_url_loc, static_folder, files, bucket,
static_folder_rel = _path_to_relative_url(static_folder)
for file_path in files:
asset_loc = _path_to_relative_url(file_path)
key_name = _static_folder_path(static_url_loc, static_folder_rel,
asset_loc).lstrip("/")
full_key_name = _static_folder_path(static_url_loc, static_folder_rel,
asset_loc)
key_name = full_key_name.lstrip("/")
msg = "Uploading %s to %s as %s" % (file_path, bucket, key_name)
logger.debug(msg)
exclude = False
if app.config.get('S3_ONLY_MODIFIED', False):
file_hash = hash_file(file_path)
new_hashes.append((key_name, file_hash))
new_hashes.append((full_key_name, file_hash))
if hashes and hashes.get(key_name, None) == file_hash:
if hashes and hashes.get(full_key_name, None) == file_hash:
exclude = True
if ex_keys and key_name in ex_keys or exclude:
if ex_keys and full_key_name in ex_keys or exclude:
logger.debug("%s excluded from upload" % key_name)
else:
with open(file_path) as fp: