Skip to content
This repository has been archived by the owner on Apr 13, 2024. It is now read-only.

Implement filesystem functions for node.js #19

Merged
merged 8 commits into from
Feb 15, 2024

Conversation

AtkinsSJ
Copy link
Contributor

I've attempted to match the behaviour of puter/filesystem.js as much as possible. I've updated a couple of the builtins, but I haven't thoroughly checked all of them, these are just the ones I noticed needed changes when using them to test the filesystem API.

Contributes to #14.

@@ -48,7 +49,11 @@ export default {
try {
stat = await filesystem.stat(path);
} catch (e) {
if ( e.code !== 'subject_does_not_exist' ) throw e;
if ( POSIX ) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This gives me an idea; we should probably translate errors inside platform support. filesystem.capabilities is meant to represent more significant filesystem differences (ex: puter directories can be associated with subdomains, ACL vs POSIX-style permissions, etc)

I like the idea of having an object called ERR_NO_ENTITY (could have properties like posixLabel: 'ENOENT', description: '...') - then it's just an object reference comparison instead of a string comparison here too.

I might merge this first and then we can change this after.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense! The less the builtins have to know/care about the platform, the better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can't find any documentation for Puter SDK errors. I'd need to know their codes to be able to translate them - and generally it would be useful for API users if https://docs.puter.com listed the errors for each API call.

src/platform/node/filesystem.js Show resolved Hide resolved
@KernelDeimos KernelDeimos merged commit 8c8317c into HeyPuter:trunk Feb 15, 2024
@AtkinsSJ AtkinsSJ deleted the node-cli-fs branch February 16, 2024 10:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants