@@ -614,6 +614,25 @@ static void getPackageCountsBedrock(FFstrbuf* baseDir, FFPackagesResult* package
614614 ffStrbufSubstrBefore (baseDir , baseDirLength );
615615}
616616
617+ static uint32_t getInstallReleasePackages (FFstrbuf * baseDir ) {
618+ uint32_t result = 0 ;
619+
620+ uint32_t baseDirLength = baseDir -> length ;
621+ ffStrbufAppendS (baseDir , ".config/install_release/state.json" );
622+ if (ffPathExists (baseDir -> chars , FF_PATHTYPE_ANY )) {
623+ yyjson_doc * doc = yyjson_read_file (baseDir -> chars , YYJSON_READ_NOFLAG , NULL , NULL );
624+ if (doc != NULL ) {
625+ yyjson_val * root = yyjson_doc_get_root (doc );
626+ if (yyjson_is_obj (root )) {
627+ result = (uint32_t ) yyjson_obj_size (root );
628+ }
629+ yyjson_doc_free (doc );
630+ }
631+ }
632+ ffStrbufSubstrBefore (baseDir , baseDirLength );
633+ return result ;
634+ }
635+
617636void ffDetectPackagesImpl (FFPackagesResult * result , FFPackagesOptions * options ) {
618637 FF_STRBUF_AUTO_DESTROY baseDir = ffStrbufCreateA (512 );
619638 ffStrbufAppendS (& baseDir , FASTFETCH_TARGET_DIR_ROOT );
@@ -677,18 +696,7 @@ void ffDetectPackagesImpl(FFPackagesResult* result, FFPackagesOptions* options)
677696 result -> appimage += getNumElementsBySuffix (& baseDir , "/Applications" , ".appimage" );
678697 }
679698
680- if (!(options -> disabled & FF_PACKAGES_FLAG_INSTALLRELEASE_BIT )) {
681- FF_STRBUF_AUTO_DESTROY path = ffStrbufCreateCopy (& baseDir );
682- ffStrbufAppendS (& path , ".config/install_release/state.json" );
683- if (ffPathExists (path .chars , FF_PATHTYPE_FILE )) {
684- yyjson_doc * doc = yyjson_read_file (path .chars , YYJSON_READ_NOFLAG , NULL , NULL );
685- if (doc != NULL ) {
686- yyjson_val * root = yyjson_doc_get_root (doc );
687- if (yyjson_is_obj (root )) {
688- result -> installrelease = (uint32_t ) yyjson_obj_size (root );
689- }
690- yyjson_doc_free (doc );
691- }
692- }
699+ if (FF_PACKAGES_IS_ENABLED (options , INSTALLRELEASE )) {
700+ result -> installrelease = getInstallReleasePackages (& baseDir );
693701 }
694702}
0 commit comments