thephpleague / flysystem

Abstraction for local and remote filesystems
https://flysystem.thephpleague.com
MIT License
13.37k stars 827 forks source link

Add MongoDB GridFS Adapter #1794

Closed GromNaN closed 5 months ago

GromNaN commented 6 months ago

GridFS is a file system that uses MongoDB as storage. I would like to propose this adapter which uses the MongoDB PHP Library.

Docs PR: https://github.com/thephpleague/flysystem/pull/1795

The legacy GridFS Flysystem adapter had some significant number of installations, even if it used the legacy Mongo extension. It shows there's some interest.

Important notes:

frankdejonge commented 6 months ago

Hi all, I'm out this week but will get on this ASAP to get this out. Thanks for the effort and the interest to contribute. Would there be anybody interested from your end to do continued maintenance in this adapter? And if so, who? Then I know who to rope in with issues.

GromNaN commented 6 months ago

Hello Frank, we are a team of currently 3 devs, led by @alcaeus. We use an open Jira to organise our work and Flysystem is one of the packages we want to maintain.

frankdejonge commented 5 months ago

Looks like the test case GridFSAdapterTest::move_all_revisions is failing.

GromNaN commented 5 months ago

Looks like the test case GridFSAdapterTest::move_all_revisions is failing.

Where do you see that? It seems to work in GitHub Actions: https://github.com/thephpleague/flysystem/actions/runs/9161336038/job/25242807530?pr=1794

frankdejonge commented 5 months ago

@GromNaN this is an example; https://github.com/thephpleague/flysystem/actions/runs/9180056390/job/25244027378?pr=1794 might be because of eventual consistency in MongoDB? Is that a thing? Previous run had more errors on the same test case.

GromNaN commented 5 months ago

Ok, I suspect that it's because 2 files are created in the same millisecond and revisions are sorted using this date.

frankdejonge commented 5 months ago

@GromNaN still one failing, is there another way to deal with this or to configure it? https://github.com/GromNaN/flysystem/actions/runs/9181466558/job/25248713035

GromNaN commented 5 months ago

It seems that my previous guess was correct but the fix incorrectly implemented. I added usleep(1000) (1ms) between each insertion of a revision to have a different uploadDate.