@@ -198,15 +198,21 @@ pub async fn get_repo_data(
198198 default_branch_name. as_ref ( )
199199 } ;
200200
201- let ( build_zig_zon_data, ( readme_url, readme_content) ) = tokio:: join!(
201+ let ( build_zig_zon_data, ( readme_url, readme_content) , default_branch_directory_files ) = tokio:: join!(
202202 get_build_zig_zon_data_wrapper( & repository. owner. login, & repository. name, branch, client) ,
203203 get_readme_url_and_content(
204204 & repository. owner. login,
205205 & repository. name,
206206 branch,
207207 true ,
208208 client
209- )
209+ ) ,
210+ fetch_root_folder_directory_files_wrapper(
211+ & repository. owner. login,
212+ & repository. name,
213+ branch,
214+ client
215+ ) ,
210216 ) ;
211217
212218 let ( readme_url, readme_content) = match ( readme_url, readme_content) {
@@ -223,20 +229,24 @@ pub async fn get_repo_data(
223229 let release_clone = release. clone ( ) ;
224230
225231 async move {
226- let ( readme_url, _) =
227- match get_readme_url_and_content ( & owner, & name, & tag, false , client) . await {
228- ( Some ( url) , _) => ( url, String :: new ( ) ) ,
229- _ => ( "404 unable to find readme." . to_string ( ) , String :: new ( ) ) ,
230- } ;
231-
232- let bzz_results = get_build_zig_zon_data_wrapper ( & owner, & name, & tag, client) . await ;
232+ let ( ( readme_url, _) , bzz_results, directory_files) = tokio:: join!(
233+ async {
234+ match get_readme_url_and_content( & owner, & name, & tag, false , client) . await {
235+ ( Some ( url) , _) => ( url, String :: new( ) ) ,
236+ _ => ( "404 unable to find readme." . to_string( ) , String :: new( ) ) ,
237+ }
238+ } ,
239+ get_build_zig_zon_data_wrapper( & owner, & name, & tag, client) ,
240+ fetch_root_folder_directory_files_wrapper( & owner, & name, & tag, client) ,
241+ ) ;
233242
234243 ReleaseData {
235244 tag_name : release_clone. tag_name ,
236245 is_prerelease : release_clone. is_prerelease ,
237246 published_at : release_clone. published_at ,
238247 minimum_zig_version : bzz_results. 0 ,
239248 readme_url,
249+ directory_files,
240250 dependencies : bzz_results. 1 ,
241251 }
242252 }
@@ -261,6 +271,7 @@ pub async fn get_repo_data(
261271 readme_content : readme_processed_content,
262272 build_zig_zon_version : build_zig_zon_data. 0 ,
263273 build_zig_zon_dependencies : build_zig_zon_data. 1 ,
274+ default_branch_directory_files,
264275 releases,
265276 }
266277}
@@ -275,6 +286,7 @@ pub async fn persist_repo_data(transaction: &Transaction, data: RepoData) {
275286 readme_content,
276287 build_zig_zon_version,
277288 build_zig_zon_dependencies,
289+ default_branch_directory_files,
278290 releases,
279291 } = data;
280292
@@ -439,13 +451,14 @@ pub async fn persist_repo_data(transaction: &Transaction, data: RepoData) {
439451 . query (
440452 r#"
441453 INSERT INTO releases
442- (repo_id, version, is_prerelease, published_at, minimum_zig_version, readme_url)
443- VALUES(?, ?, ?, ?, ?, ?)
454+ (repo_id, version, is_prerelease, published_at, minimum_zig_version, readme_url, directory_files )
455+ VALUES(?, ?, ?, ?, ?, ?, ? )
444456 ON CONFLICT(repo_id, version) DO UPDATE SET
445457 is_prerelease = excluded.is_prerelease,
446458 published_at = excluded.published_at,
447459 minimum_zig_version = excluded.minimum_zig_version,
448- readme_url = excluded.readme_url
460+ readme_url = excluded.readme_url,
461+ directory_files = excluded.directory_files
449462 RETURNING id
450463 "# ,
451464 params ! [
@@ -461,6 +474,10 @@ pub async fn persist_repo_data(transaction: &Transaction, data: RepoData) {
461474 limits:: RELEASE_MIN_ZIG_VERSION_MAX_LEN
462475 ) ,
463476 readme_url. clone( ) ,
477+ truncate_to_char_limit(
478+ & default_branch_directory_files,
479+ limits:: RELEASE_DIRECTORY_FILES_MAX_LEN
480+ ) ,
464481 ] ,
465482 )
466483 . await
@@ -519,13 +536,14 @@ pub async fn persist_repo_data(transaction: &Transaction, data: RepoData) {
519536 . query (
520537 r#"
521538 INSERT INTO releases
522- (repo_id, version, is_prerelease, published_at, minimum_zig_version, readme_url)
523- VALUES(?, ?, ?, ?, ?, ?)
539+ (repo_id, version, is_prerelease, published_at, minimum_zig_version, readme_url, directory_files )
540+ VALUES(?, ?, ?, ?, ?, ?, ? )
524541 ON CONFLICT(repo_id, version) DO UPDATE SET
525542 is_prerelease = excluded.is_prerelease,
526543 published_at = excluded.published_at,
527544 minimum_zig_version = excluded.minimum_zig_version,
528- readme_url = excluded.readme_url
545+ readme_url = excluded.readme_url,
546+ directory_files = excluded.directory_files
529547 RETURNING id
530548 "# ,
531549 params ! [
@@ -538,6 +556,10 @@ pub async fn persist_repo_data(transaction: &Transaction, data: RepoData) {
538556 limits:: RELEASE_MIN_ZIG_VERSION_MAX_LEN
539557 ) ,
540558 release_data. readme_url,
559+ truncate_to_char_limit(
560+ & release_data. directory_files,
561+ limits:: RELEASE_DIRECTORY_FILES_MAX_LEN
562+ ) ,
541563 ] ,
542564 )
543565 . await
@@ -1074,6 +1096,25 @@ async fn get_build_zig_zon_data_wrapper(
10741096 }
10751097}
10761098
1099+ async fn fetch_root_folder_directory_files_wrapper (
1100+ owner_name : & str ,
1101+ repo_name : & str ,
1102+ branch_or_tag : & str ,
1103+ client : & reqwest:: Client ,
1104+ ) -> String {
1105+ match cron_update_helper:: fetch_root_folder_directory_files (
1106+ client,
1107+ owner_name. to_string ( ) ,
1108+ repo_name. to_string ( ) ,
1109+ branch_or_tag. to_string ( ) ,
1110+ )
1111+ . await
1112+ {
1113+ Ok ( files) => files,
1114+ Err ( _) => String :: new ( ) ,
1115+ }
1116+ }
1117+
10771118/// I have added this new client, which is much more optimized
10781119/// becuase, initially, I wasn't adding any timeouts.
10791120fn create_optimized_client ( ) -> reqwest:: Client {
0 commit comments