duna-oss / flystorage

Flystorage; File storage abstraction for Node / TypeScript
https://flystorage.dev/
183 stars 13 forks source link

Path problems on Windows #19

Open gtflip opened 7 months ago

gtflip commented 7 months ago

Since it uses path.join in several places, on Windows it creates a path string with backslashes in it instead of slashes. This doesn't work as expected for an AWS S3 key (the only module I've tested with so far). I changed a few imports from "node:path" to "node:path/posix", which allowed me to use it on Windows.

I got it compiling from github on Windows using cross-env and fse-cli, but obviously I don't have access to your S3 bucket for testing, e.g., so I stopped working on that for now.

frankdejonge commented 7 months ago

Cheers, I'll look into this.

frankdejonge commented 7 months ago

I've just pushed a change that swaps the normal path functions for the posix kind. It's injected in, so the other adapters keep working too.

frankdejonge commented 7 months ago

@gtflip a new version is out which I hope addresses this. Could you verify?

gtflip commented 7 months ago

Unfortunately not. It's happening in PathNormalizerV1.normalizePath and PathPrefixer. I changed my copies in node_modules to do import { join } from 'node:path/posix'; and that worked for my S3 tests. I don't know if that fits in with the way you want to do things.

I just use FileStorage.read() and FileStorage.stat() right now, though, so it's not a full test.

gtflip commented 7 months ago

I got testing running on my Windows system. Looks like it's not a simple fix for local-fs. I'll see if I can get those two working on Windows.

frankdejonge commented 7 months ago

We'll have to make sure that CI is also able to validate the implementation. I'll try to see if I can mooch off some prior art somewhere.