Comments (3)
Relevant PHP documentation for behaviour of fopen
'x' | Create and open for writing only; place the file pointer at the beginning of the file. If the file already exists, the fopen() call will fail by returning FALSE and generating an error of level E_WARNING. If the file does not exist, attempt to create it. This is equivalent to specifying O_EXCL|O_CREAT flags for the underlying open(2) system call.
https://www.php.net/manual/en/function.fopen.php
I think the issue there is the need to have some distributed lock system. Technically once your filesystem is on a network locks need to be enforced on the network, which they cannot be using some of the flysystem backends, which don't support file/object-level locking.
A Person could add a redis or similar fast network key-value store which supports locking, but then you have a whole new set of dependencies and class of problems to solve.
I'd recommend perhaps the addition of a locking interface to use when this is required; but then marking this as fixed
or wontfix
because there can be no generic one-size solution to this.
from flysystem-stream-wrapper.
I think the issue there is the need to have some distributed lock system. Technically once your filesystem is on a network locks need to be enforced on the network, which they cannot be using some of the flysystem backends, which don't support file/object-level locking.
When using those backends that don't support file/object-level locking, any call to fopen($file, 'x')
(or other locking flags) should fail as if the filesystem couldn't be read I would imagine. It should not pretend to succeed.
from flysystem-stream-wrapper.
Seems like PHP via flock could be interpreted to agree.
Note:
May only be used on file pointers returned by fopen() for local files, or file pointers pointing to userspace streams that implement the streamWrapper::stream_lock() method.
hints about the interface implementation are then given
Warning
On some operating systems flock() is implemented at the process level. When using a multithreaded server API like ISAPI you may not be able to rely on flock() to protect files against other PHP scripts running in parallel threads of the same server instance!
flock() is not supported on antiquated filesystems like FAT and its derivates and will therefore always return FALSE under these environments.
However... Crucially I think perhaps the following gives a hint at a more permissive interpretation.
When using a multithreaded server API like ISAPI you may not be able to rely on flock() to protect files against other PHP scripts running in parallel threads of the same server instance!
There are already examples of where flock
the primary file-locking mechanism of the language falls apart on same-server. To suggest a distributed implementation should handle the intricacies is problematic.
The two places this would make sense to complain to would be flysystem, or PHP
from flysystem-stream-wrapper.
Related Issues (19)
- Unlink returns invalid values with Dropbox adapter HOT 7
- exif_read_data(): File not supported HOT 5
- v1.0.9 release? HOT 2
- Calls to `uri_stat()` triggers a notice HOT 15
- Call to move_uploaded_file() always returns true HOT 13
- What is the alive status of this project?
- Injectable Locking interface
- Twistor\FlysystemStreamWrapper::stream_stat() sets size to 0 for at least some remote files, can result in empty files being written HOT 1
- stat()/file_exists() always returns on non-existent files with AWS adapter HOT 1
- fstat called within getSize is returning a boolean value, not an array, so getting a notice that 'size' is undefined HOT 1
- Incompatible with v2 of Flysystem HOT 1
- Incompatible with PHP 8.2 HOT 1
- Fix OSX tests.
- PHP Warning: ftell(): supplied resource is not a valid stream resource HOT 5
- is_writable always return false HOT 3
- stream_wrapper_register missing STREAM_IS_URL param HOT 2
- Warning: fwrite(): SSL: Broken pipe HOT 2
- Warning: fseek(): supplied resource is not a valid stream resource
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 flysystem-stream-wrapper.