-
Notifications
You must be signed in to change notification settings - Fork 1
Extract hydrate file #187
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
Merged
Merged
Extract hydrate file #187
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
21bd1ad
Create napi safe wrap
dajimenezriv-internxt 819a1f1
Extract create folder placeholder
dajimenezriv-internxt cc1b678
Extract create file placeholder
dajimenezriv-internxt 444a2d5
Extract get file identity
dajimenezriv-internxt b5eff5e
Update package.json
dajimenezriv-internxt fe31746
Extract connect sync root
dajimenezriv-internxt 32c5ea9
Extract hydrate file
dajimenezriv-internxt f205837
Merge branch 'master' into extract-hydrate-file
dajimenezriv-internxt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| #pragma once | ||
|
|
||
| #include <node_api.h> | ||
|
|
||
| napi_value hydrate_file_impl(napi_env env, napi_callback_info args); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| #include <Windows.h> | ||
| #include "Logger.h" | ||
| #include "SyncRoot.h" | ||
|
|
||
| napi_value hydrate_file_impl(napi_env env, napi_callback_info args) | ||
| { | ||
| size_t argc = 1; | ||
| napi_value argv[1]; | ||
| napi_value thisArg; | ||
| napi_get_cb_info(env, args, &argc, argv, &thisArg, nullptr); | ||
|
|
||
| if (argc < 1) | ||
| { | ||
| napi_throw_type_error(env, nullptr, "The file path is required for HydrateFile"); | ||
| return nullptr; | ||
| } | ||
|
|
||
| // Obtener el argumento de JavaScript y convertirlo a una cadena de C++ | ||
| size_t pathLength; | ||
| napi_get_value_string_utf16(env, argv[0], nullptr, 0, &pathLength); | ||
| std::wstring fullPath(pathLength, L'\0'); | ||
| napi_get_value_string_utf16(env, argv[0], reinterpret_cast<char16_t *>(&fullPath[0]), pathLength + 1, nullptr); | ||
|
|
||
| // Crear una promesa | ||
| napi_deferred deferred; | ||
| napi_value promise; | ||
| napi_create_promise(env, &deferred, &promise); | ||
|
|
||
| // Lanzar la operación asíncrona en un hilo separado | ||
| std::thread([deferred, fullPath, env]() | ||
| { | ||
| try { | ||
| SyncRoot::HydrateFile(fullPath.c_str()); | ||
| Logger::getInstance().log("finish... " + Logger::fromWStringToString(fullPath.c_str()), LogLevel::INFO); | ||
|
|
||
| napi_value result; | ||
| napi_get_undefined(env, &result); | ||
| napi_resolve_deferred(env, deferred, result); | ||
| } catch (const std::exception& e) { | ||
| napi_value error; | ||
| napi_create_string_utf8(env, e.what(), NAPI_AUTO_LENGTH, &error); | ||
| napi_reject_deferred(env, deferred, error); | ||
| } catch (...) { | ||
| napi_value error; | ||
| napi_create_string_utf8(env, "Unknown error", NAPI_AUTO_LENGTH, &error); | ||
| napi_reject_deferred(env, deferred, error); | ||
| } }) | ||
| .detach(); | ||
|
|
||
| wprintf(L"FINISHHHHHn"); | ||
|
|
||
| return promise; | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.