-
Notifications
You must be signed in to change notification settings - Fork 1
Simplify create file and folder placeholder #201
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
Conversation
| @@ -5,7 +5,7 @@ on: | |||
| types: [published] | |||
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.
This was fixed since the last version but it was not merged.
|
| @@ -1,29 +1,47 @@ | |||
| #include <Windows.h> | |||
| #include <filesystem> | |||
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.
This function coverts an item to placeholder. It can be either a file or a folder. First we check if it's a folder, then we create a handle of the item and using winrt::file_handle this handle is automatically closed when the function finishes so we don't have to manually do CloseHandle. After that we just call the Cloud Files API function CfConvertToPlaceholder with the item handler, the placeholderId and some other things that were already there before. We ignore the exception of this item was already a placeholder and we throw in case we have another error with winrt::check_hresult.
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.
In the previous code we had
HRESULT hrPinState = CfSetPinState(fileHandle, CF_PIN_STATE_PINNED, CF_SET_PIN_FLAG_NONE, nullptr);but I removed and it seems that the pin state is already handled internally and we don't need to manually set that the file is pinned (the content is available in local).
| @@ -1,42 +1,42 @@ | |||
| #include <Windows.h> | |||
| #include <filesystem> | |||
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.
This function is the same as create_folder_placeholder. First we convert the times from javascript time to windows time. Then we check that the file doesn't exist yet.
If it exists, then instead of creating a placeholder from 0, we just convert the already existing file into a placeholder using conver_to_placeholder (the function from the above file). Placeholders::MantainIdentity was called in the previous code too but I need to investigate what it does.
If it doesn't exist, we just create the cloudEntry and call the Cloud Files API CfCreatePlaceholders. In case there is an error it will throw automatically an exception using winrt::check_hresult.
UpdatePinState was also used in the previous code, but it seems to not be need. I left the comment to remember but probably it can be removed.


No description provided.