Skip to content

Conversation

@dajimenezriv-internxt
Copy link
Contributor

No description provided.

@dajimenezriv-internxt dajimenezriv-internxt self-assigned this Sep 26, 2025
@dajimenezriv-internxt dajimenezriv-internxt changed the title Update publish.yml Simplify create file and folder placeholder Oct 23, 2025
@@ -5,7 +5,7 @@ on:
types: [published]
Copy link
Contributor Author

@dajimenezriv-internxt dajimenezriv-internxt Oct 23, 2025

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.

@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

@@ -1,29 +1,47 @@
#include <Windows.h>
#include <filesystem>
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 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.

Copy link
Contributor Author

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>
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 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.

@dajimenezriv-internxt dajimenezriv-internxt merged commit b81af70 into master Oct 24, 2025
3 of 4 checks passed
@dajimenezriv-internxt dajimenezriv-internxt deleted the fix-publish branch October 24, 2025 15:15
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