ipfs / go-ds-flatfs

A datastore implementation using sharded directories and flat files to store data
MIT License
46 stars 21 forks source link

Add os.Rename wrapper for Plan 9 #87

Closed fhs closed 4 years ago

fhs commented 4 years ago

os.Rename documentation says: "OS-specific restrictions may apply when oldpath and newpath are in different directories." On Unix, this means we can't rename across devices. On Plan 9 however, the functionality is even more limited: cross-directory renames are not allowed at all.

Add a wrapper around os.Rename for Plan 9, which will copy the file if we're renaming across directory. All tests seems to pass.

(Aside: I also had to write this wrapper to get go-git working on Plan 9: https://github.com/go-git/go-billy/blob/v5.0.0/osfs/os_plan9.go#L27 but I notice few issues with that one.)

Fixes #86

welcome[bot] commented 4 years ago

Thank you for submitting this PR! A maintainer will be here shortly to review it. We are super grateful, but we are also overloaded! Help us by making sure that:

Getting other community members to do a review would be great help too on complex PRs (you can ask in the chats/forums). If you are unsure about something, just leave us a comment. Next steps:

We currently aim to provide initial feedback/triaging within two business days. Please keep an eye on any labelling actions, as these will indicate priorities and status of your contribution. We are very grateful for your contribution!

willscott commented 4 years ago

I didn't look particularly carefully at this one yet, but the logic seems fine. I am wondering if maybe this is impetus for getting tests to run in CI for this repo, so that we don't accidentally break plan9.

I'm not fully sure if any of the CIs IPFS has been using have support for plan9 runners. that's probably an assumption to check first before seeing if that's worth doing.

fhs commented 4 years ago

I don't think any of the CIs IPFS uses supports Plan 9. I would be happy with just checking if cross compiling to GOOS=plan9 works. We can do that in the main go-ipfs repo once few more fixes (coming up) lands.

willscott commented 4 years ago

to confirm though, cross compiling GOOS=plan9 would not catch this issue, which would be caught by the test suite, but not by compilation alone.

fhs commented 4 years ago

to confirm though, cross compiling GOOS=plan9 would not catch this issue, which would be caught by the test suite, but not by compilation alone.

Correct. I don't see any easy way of running the tests. The only public Plan 9 CI I know of is the one from sr.ht but I never got it to work correctly. The Go project has a custom solution: https://farmer.golang.org/builders

To clarify, I originally found out about the os.Rename issue when ipfs init was failing. When things are as broken as it is now on Plan 9, we'll find the issues without running the tests. That is of course not a good reason to not set up CI if we can.

willscott commented 4 years ago

agreed - i also don't see a great way to automate keeping this from breaking in the future. Your plan seems reasonable for now.