@@ -16,7 +16,7 @@ def lambda_handler(event, context):
1616 prefix = '/' .join (key .split ('/' )[0 :- 1 ])+ '/'
1717
1818 s3_repo_dir = os .environ ['REPO_DIR' ].strip ('/' )
19-
19+
2020 #make sure we are working with correct files
2121 if bucket == os .environ ['BUCKET_NAME' ] and key .endswith (".rpm" ) and prefix .startswith (s3_repo_dir ):
2222 #check if repodata already exist, if not create new with key file
@@ -39,7 +39,7 @@ def lambda_handler(event, context):
3939 repo , cache = check_changed_files (repo , s3_repo_dir )
4040 #save cache to bucket
4141 s3 = boto3 .resource ('s3' )
42- f_index_obj = s3 .Object (bucket_name = os .environ ['BUCKET_NAME' ], key = s3_repo_dir + '/repo_cache' )
42+ f_index_obj = s3 .Object (bucket_name = os .environ ['BUCKET_NAME' ], key = os . environ [ 'CACHE' ] + '/repo_cache' )
4343 print ("Writing file: %s" % (str (f_index_obj )))
4444 f_index_obj .put (Body = str (json .dumps (cache )))
4545
@@ -106,10 +106,10 @@ def get_cache(repo, s3_repo_dir):
106106 """
107107 Check for cache file
108108 """
109- if check_bucket_file_existance (s3_repo_dir + '/repo_cache' ):
110- print ('Repodata cache (%s) found, attempting to write to it' % (s3_repo_dir + '/repo_cache' ))
109+ if check_bucket_file_existance (os . environ [ 'CACHE' ] + '/repo_cache' ):
110+ print ('Repodata cache (%s) found, attempting to write to it' % (os . environ [ 'CACHE' ] + '/repo_cache' ))
111111 s3 = boto3 .client ('s3' )
112- s3 .download_file (os .environ ['BUCKET_NAME' ], s3_repo_dir + '/repo_cache' , repo .repodir + 'repo_cache' )
112+ s3 .download_file (os .environ ['BUCKET_NAME' ], os . environ [ 'CACHE' ] + '/repo_cache' , repo .repodir + 'repo_cache' )
113113 with open (repo .repodir + 'repo_cache' , 'r' ) as f :
114114 cache = json .loads (f .read (- 1 ))
115115 else :
@@ -128,7 +128,7 @@ def remove_overwritten_file_from_cache(cache, newfile, s3_repo_dir, repo):
128128
129129 # save cache in case new event occurs
130130 s3 = boto3 .resource ('s3' )
131- f_index_obj = s3 .Object (bucket_name = os .environ ['BUCKET_NAME' ], key = s3_repo_dir + '/repo_cache' )
131+ f_index_obj = s3 .Object (bucket_name = os .environ ['BUCKET_NAME' ], key = os . environ [ 'CACHE' ] + '/repo_cache' )
132132 f_index_obj .put (Body = str (json .dumps (cache )))
133133
134134 repo .remove_package (pkg_id )
0 commit comments