@@ -266,7 +266,7 @@ def re_index(
266266 path : str ,
267267 package_type : str ,
268268 aws_profile : str = None ,
269- # cf_enable : bool = False,
269+ recursive : bool = False ,
270270 dry_run : bool = False
271271):
272272 """Refresh the index.html for the specified folder in the bucket.
@@ -306,17 +306,31 @@ def re_index(
306306 logger .debug ("The re-indexed page content: %s" , index_content )
307307 if not dry_run :
308308 index_path = os .path .join (path , "index.html" )
309+ logger .info ("Start re-indexing %s in bucket %s" , index_path , bucket_name )
309310 if path == "/" :
310311 index_path = "index.html"
311312 s3_client .simple_delete_file (index_path , (bucket_name , real_prefix ))
312313 s3_client .simple_upload_file (
313314 index_path , index_content , (bucket_name , real_prefix ),
314315 "text/html" , digest_content (index_content )
315316 )
316- # We will not invalidate index.html per cost consideration
317- # if cf_enable:
318- # cf_client = CFClient(aws_profile=aws_profile)
319- # invalidate_cf_paths(cf_client, bucket, [index_path])
317+ logger .info ("%s re-indexing finished" , index_path )
318+ if recursive :
319+ for c in contents :
320+ if c .endswith ("/" ):
321+ sub_path = c .removeprefix (real_prefix ).strip ()
322+ if sub_path .startswith ("/" ):
323+ sub_path = sub_path .removeprefix ("/" )
324+ logger .debug ("subpath: %s" , sub_path )
325+ args = {
326+ "target" : target ,
327+ "path" : sub_path ,
328+ "package_type" : package_type ,
329+ "aws_profile" : aws_profile ,
330+ "recursive" : recursive ,
331+ "dry_run" : dry_run
332+ }
333+ re_index (** args ) # type: ignore
320334 else :
321335 logger .warning (
322336 "The path %s does not contain any contents in bucket %s. "
0 commit comments