Skip to content

Migrate fetch data to C##1397

Open
dajimenezriv-internxt wants to merge 16 commits into
add-addon-C#from
migrate-fetch-data-to-c#
Open

Migrate fetch data to C##1397
dajimenezriv-internxt wants to merge 16 commits into
add-addon-C#from
migrate-fetch-data-to-c#

Conversation

@dajimenezriv-internxt

@dajimenezriv-internxt dajimenezriv-internxt commented May 27, 2026

Copy link
Copy Markdown
Contributor

What

Implemennt the fetch data callback in C#. This is the callback that happens when a user tries to hydrate a file using double click on that file. Basically we connect the callbacks in C# using connectSyncRoot, when a user tries to fetch a file we receive an event in C#. From C# we call the callback of javascript for download the file that he have registered in connectSyncRoot. From the javascript code we download the file and we call a callback in C# for every piece of bytes that we receive. The C# code starts hydrating the placeholder and sending the progress to windows.

@dajimenezriv-internxt dajimenezriv-internxt self-assigned this May 27, 2026
}
}

public static Task HydrateFile(string path) => Task.Run(() =>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Just extract these functions into Placeholder.cs.

{
private static readonly ConcurrentDictionary<string, FileWatcher> _watchers = new();

public static JSValue WatchPath(string rootPath, JSValue onEvent)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Instead of using an object for tracking active watchers we use an guid string.


namespace Intx.Addon;

internal static class Placeholder

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The same code as before.

progressCallback: (progress) => void progressCallback(progress),
});

LocalSync.SyncState.addItem({ action: 'UPLOADING', path, progress: 1 });

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

After the download has been completed we put the progress to 100%, otherwise we don't receive the last progress notification from inxt-js and it leaves the file like at 96% or whatever until is created on drive-server-wip.

var evt = JSValue.CreateObject();
evt["action"] = "error";
evt["path"] = message;
evt["message"] = message;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The variable is not really used in javascript (we just log the event when action is error), however, since in C++ we were using the same struct it was called path but it makes more sense to be called message since it contains the error message.

@sonarqubecloud

Copy link
Copy Markdown

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