Refactor cancel fetch data#197
Conversation
|
| class Utilities | ||
| { | ||
| public: | ||
| static void AddFolderToSearchIndexer(_In_ LPCWSTR folder); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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); | ||
|
|
||
| { |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
We can't return since we need to change ready to true, otherwise we are not releasing the mutex lock.


No description provided.