@@ -519,6 +519,31 @@ static inline uint32_t getFlatpakRuntimePackages(FFstrbuf* baseDir)
519519 return num_elements ;
520520}
521521
522+ static inline uint32_t getFlatpakAppPackages (FFstrbuf * baseDir )
523+ {
524+ ffStrbufAppendS (baseDir , "app/" );
525+ FF_AUTO_CLOSE_DIR DIR * dirp = opendir (baseDir -> chars );
526+ if (dirp == NULL )
527+ return 0 ;
528+
529+ uint32_t appDirLength = baseDir -> length ;
530+ uint32_t num_elements = 0 ;
531+
532+ struct dirent * entry ;
533+ while ((entry = readdir (dirp )) != NULL )
534+ {
535+ if (entry -> d_type == DT_DIR && entry -> d_name [0 ] != '.' )
536+ {
537+ ffStrbufAppendS (baseDir , entry -> d_name );
538+ ffStrbufAppendS (baseDir , "/current" );
539+ if (ffPathExists (baseDir -> chars , FF_PATHTYPE_ANY )) // Exclude deleted apps, #1856
540+ ++ num_elements ;
541+ ffStrbufSubstrBefore (baseDir , appDirLength );
542+ }
543+ }
544+ return num_elements ;
545+ }
546+
522547static uint32_t getFlatpakPackages (FFstrbuf * baseDir , const char * dirname )
523548{
524549 uint32_t num_elements = 0 ;
@@ -527,8 +552,7 @@ static uint32_t getFlatpakPackages(FFstrbuf* baseDir, const char* dirname)
527552 ffStrbufAppendS (baseDir , "/flatpak/" );
528553 uint32_t flatpakDirLength = baseDir -> length ;
529554
530- ffStrbufAppendS (baseDir , "app" );
531- num_elements += ffPackagesGetNumElements (baseDir -> chars , true);
555+ num_elements += getFlatpakAppPackages (baseDir );
532556 ffStrbufSubstrBefore (baseDir , flatpakDirLength );
533557
534558 num_elements += getFlatpakRuntimePackages (baseDir );
0 commit comments