Comments (7)
I see a couple of places in the code, where OS support is hardwired for babashka.fs/file-separator.
Can you be more specific, or just provide a PR to fix it?
from fs.
I've read the issue again and now understand it better, but I'd like to have very specific examples / test cases of what currently fails with the "hard-coded" approach, i.e. a repro. We can deprecate babashka.fs/file-separator
in favor of a new function and use that instead to make the test(s) pass.
from fs.
i can prepare a repo for you in the next few hours, to demonstrate my specific use-cases with both S3 filesystem provider and Jimfs in-memory provider.
i gave a lot of thoughts how would I address this problem, but I'm not sure.
we made a tiny wrapper in our project to explore different approaches, but none of them were very satisfactory, that's why I haven't followed up on the issue yet.
from fs.
ok sorry for sounding impatient. the jimfs thing sounds like it could work in the unit tests, s3 is a bit more complicated.
just a zip filesystem could also work since the file separator is always "/" there, even on Windows
from fs.
Made a repro repo:
https://github.com/onetom/babashka-fs-issue-111
Here is one symptom of not taking into account of the file system of a Path
:
(-> s3-path (fs/path "test.txt"))
; Execution error (UnsupportedOperationException)
; at software.amazon.nio.spi.s3.S3Path/toFile (S3Path.java:729).
; S3 Objects cannot be represented in the local (default) file system
For further context see the repl.s3
namespace.
I will commit some Jimfs examples too tomorrow.
from fs.
Pushed some Jimfs examples too.
Regarding the implementation, here are some observations:
- The
path
&as-path
functions are callingio/file
, involves the legacyjava.io.File
concept, which doesn't support pluggable file systems, if i understand it correctly, so that could be the reason for some of thejimfs://
&s3://
errors I've experienced before. java.nio.file.Paths
class is deprecated in favor ofPath/of
.- appending to an existing Path can be done by
Path#resolve
&Path#resolveSibling
, so we can avoid involvingio/file
there too.
In light of these, here are some proposed changes.
Use Path/of
:
(defn- as-path
^Path [path]
(cond
(instance? Path path) path
(instance? URI path) (Path/of path)
(instance? File path) (.toPath path)
:else (Path/of path (make-array String 0))))
this hasn't broken any existing tests.
Use Path#resolve
:
(defn path
"Coerces f into a Path. Multiple-arg versions treat the first argument as
parent and subsequent args as children relative to the parent."
(^Path [f]
(as-path f))
(^Path [parent child]
(.resolve (as-path parent) (as-path child)))
(^Path [parent child & more]
(reduce path (path parent child) more)))
this broke 5 tests, so I'll look into those later.
from fs.
Sounds good
from fs.
Related Issues (20)
- add gzip and gunzip functions
- `babashka.fs/glob` does not find directories with `.` in the name HOT 3
- Efficiently read part of a file by seek offsets HOT 3
- UnsupportedOperationException when using `copy-tree` with zip file path as source HOT 5
- Links in API.md don't work HOT 6
- comment inconsistent: fs/parent returns file no matter if it exist or not
- suggestion: fs/find-up HOT 5
- glob: hidden-option based on pattern HOT 2
- fs/match won't find things in root-folder HOT 1
- `with-temp-dir` can raise a `AccessDeniedException` exception HOT 3
- weird behaviour fs/match, fs/glob HOT 8
- copy-tree fail when some non-leaf directories in the tree are not writable HOT 3
- unzip doesn't work if source is a resource from a jar HOT 1
- Potential regression HOT 4
- Inconsistent documentation for the `:posix-file-permissions` options HOT 1
- Unclear from `fs/glob`docs that it supports a `:max-depth` option HOT 1
- Read the target path of a symbolic link HOT 2
- Consider allowing non-relative paths for fs/which HOT 4
- Add function to see file-owner
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fs.