Fix "buildcache update-index --keys ..." when mirror is S3 (#19141)
This commit is contained in:
		| @@ -350,10 +350,15 @@ def generate_key_index(key_prefix, tmpdir=None): | |||||||
|         for entry in web_util.list_url(key_prefix, recursive=False) |         for entry in web_util.list_url(key_prefix, recursive=False) | ||||||
|         if entry.endswith('.pub')) |         if entry.endswith('.pub')) | ||||||
| 
 | 
 | ||||||
|  |     remove_tmpdir = False | ||||||
|  | 
 | ||||||
|     keys_local = url_util.local_file_path(key_prefix) |     keys_local = url_util.local_file_path(key_prefix) | ||||||
|     if keys_local: |     if keys_local: | ||||||
|         target = os.path.join(keys_local, 'index.json') |         target = os.path.join(keys_local, 'index.json') | ||||||
|     else: |     else: | ||||||
|  |         if not tmpdir: | ||||||
|  |             tmpdir = tempfile.mkdtemp() | ||||||
|  |             remove_tmpdir = True | ||||||
|         target = os.path.join(tmpdir, 'index.json') |         target = os.path.join(tmpdir, 'index.json') | ||||||
| 
 | 
 | ||||||
|     index = { |     index = { | ||||||
| @@ -365,11 +370,15 @@ def generate_key_index(key_prefix, tmpdir=None): | |||||||
|         sjson.dump(index, f) |         sjson.dump(index, f) | ||||||
| 
 | 
 | ||||||
|     if not keys_local: |     if not keys_local: | ||||||
|         web_util.push_to_url( |         try: | ||||||
|             target, |             web_util.push_to_url( | ||||||
|             url_util.join(key_prefix, 'index.json'), |                 target, | ||||||
|             keep_original=False, |                 url_util.join(key_prefix, 'index.json'), | ||||||
|             extra_args={'ContentType': 'application/json'}) |                 keep_original=False, | ||||||
|  |                 extra_args={'ContentType': 'application/json'}) | ||||||
|  |         finally: | ||||||
|  |             if remove_tmpdir: | ||||||
|  |                 shutil.rmtree(tmpdir) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def build_tarball(spec, outdir, force=False, rel=False, unsigned=False, | def build_tarball(spec, outdir, force=False, rel=False, unsigned=False, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Scott Wittenburg
					Scott Wittenburg