-
-
Notifications
You must be signed in to change notification settings - Fork 638
make nix detection faster #2113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |||||||||||||||||||||||||||||||||
| #include "common/io/io.h" | ||||||||||||||||||||||||||||||||||
| #include "common/processing.h" | ||||||||||||||||||||||||||||||||||
| #include "util/stringUtils.h" | ||||||||||||||||||||||||||||||||||
| #include <stdint.h> | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| static bool isValidNixPkg(FFstrbuf* pkg) | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
|
|
@@ -51,6 +52,53 @@ static bool isValidNixPkg(FFstrbuf* pkg) | |||||||||||||||||||||||||||||||||
| return state == MATCH; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| void getNixPackagesMultiImpl(char* paths[], uint32_t counts[], FFProcessHandle handle[], uint8_t length) | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| //Implementation based on bash script from here: | ||||||||||||||||||||||||||||||||||
| //https://github.com/fastfetch-cli/fastfetch/issues/195#issuecomment-1191748222 | ||||||||||||||||||||||||||||||||||
| // no need to use hash, it is not faster | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
| // no need to use hash, it is not faster | |
| // no need to use hash, it is not faster |
Copilot
AI
Dec 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space after closing brace in for loop. Should be for (uint8_t i = 0; i < length; i++) { to be consistent with the project's coding style seen in line 73 and throughout the codebase.
Copilot
AI
Dec 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect spacing in if statement. Should have a space after 'if' to match the project's coding style as seen in line 75 and throughout the codebase. Should be if (ffPathExists(paths[i], FF_PATHTYPE_DIRECTORY)) {.
| if(ffPathExists(paths[i], FF_PATHTYPE_DIRECTORY)){ | |
| if (ffPathExists(paths[i], FF_PATHTYPE_DIRECTORY)) { |
Copilot
AI
Dec 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return value of ffProcessSpawn is not checked for errors. According to the function signature in processing.h, this function returns a const char* error message that should be checked. If the process fails to spawn, handle[i].pid might still be set to a non-zero value (depending on implementation), leading to attempts to read output from a non-existent process. The error should be checked and if non-null, handle[i].pid should remain 0.
| ffProcessSpawn((char* const[]) { | |
| "nix-store", | |
| "--query", | |
| "--requisites", | |
| paths[i], | |
| NULL | |
| }, false, &handle[i]); | |
| const char* error = ffProcessSpawn((char* const[]) { | |
| "nix-store", | |
| "--query", | |
| "--requisites", | |
| paths[i], | |
| NULL | |
| }, false, &handle[i]); | |
| if (error != NULL) | |
| handle[i].pid = 0; |
Copilot
AI
Dec 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space after closing brace in for loop. Should be for (uint8_t i = 0; i < length; i++) { to be consistent with the project's coding style.
Copilot
AI
Dec 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect spacing in if statement. Should have a space after 'if' to match the project's coding style. Should be if (!handle[i].pid) {.
| if (!handle[i].pid){ | |
| if (!handle[i].pid) { |
Copilot
AI
Dec 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return value of ffProcessReadOutput is not checked for errors. According to the function signature in processing.h, this function returns a const char* error message that should be checked. If the process fails or returns an error, the output buffer may be incomplete or invalid, leading to incorrect package counts. The error should be checked and handled appropriately.
| ffProcessReadOutput(&handle[i], &output); | |
| const char* error = ffProcessReadOutput(&handle[i], &output); | |
| if (error != NULL) | |
| { | |
| counts[i] = 0; | |
| continue; | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent formatting with extra spaces. The macro definition should have consistent spacing. Consider aligning the backslashes at a consistent column or removing extra spaces between tokens.