Skip to content

Refactor cancel fetch data#197

Merged
dajimenezriv-internxt merged 52 commits intomasterfrom
refactor-cancel-fetch-data
Sep 26, 2025
Merged

Refactor cancel fetch data#197
dajimenezriv-internxt merged 52 commits intomasterfrom
refactor-cancel-fetch-data

Conversation

@dajimenezriv-internxt
Copy link
Contributor

No description provided.

@dajimenezriv-internxt dajimenezriv-internxt self-assigned this Sep 20, 2025
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

class Utilities
{
public:
static void AddFolderToSearchIndexer(_In_ LPCWSTR folder);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer necessary, the CfRegister already adds the InternxtDrive to the file explorer and indexes it when searching for files in the search bar of the file explorer.


inline std::mutex mtx;
inline std::condition_variable cv;
inline bool ready = false;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this variables are global we can parallelize the cancel fetch data because all files would share the same variables.

#define MSSEARCH_INDEX L"SystemIndex"
DEFINE_PROPERTYKEY(PKEY_StorageProviderTransferProgress, 0xE77E90DF, 0x6271, 0x4F5B, 0x83, 0x4F, 0x2D, 0xD1, 0xF2, 0x45, 0xDD, 0xA4, 4);

void Utilities::AddFolderToSearchIndexer(_In_ PCWSTR folder)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer necessary, the CfRegister already adds the InternxtDrive to the file explorer and indexes it when searching for files in the search bar of the file explorer.

std::unique_lock<std::mutex> lock(context.mtx);
auto timeout = std::chrono::seconds(30);

{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of locking the mutext without any condition, we lock it until context.ready becomes true. We also add a timeout of 30 seconds.

if (status != napi_ok)
{
fprintf(stderr, "Failed to create threadsafe function.\n");
napi_throw_error(env, nullptr, "Failed to create cancel fetch data threadsafe function");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to throw an error in javascript if the connect function fails because we cannot register the cancel fetch data callback.

{
fprintf(stderr, "Failed to call JS function.\n");
Logger::getInstance().log("Failed to call JS function in cancelFetchCallback.", LogLevel::ERROR);
return;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't return since we need to change ready to true, otherwise we are not releasing the mutex lock.

@dajimenezriv-internxt dajimenezriv-internxt merged commit 4b2e121 into master Sep 26, 2025
3 of 4 checks passed
@dajimenezriv-internxt dajimenezriv-internxt deleted the refactor-cancel-fetch-data branch September 26, 2025 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants