Code Monkey home page Code Monkey logo

flysystem-stream-wrapper's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

flysystem-stream-wrapper's Issues

visibility can still cause exceptions

To prevent the visibility problem there is a try catch around this operation

        try {
            $visibility = $current->filesystem->visibility($current->file);
        } catch (UnableToRetrieveMetadata $e) {
            if (!$current->ignoreVisibilityErrors()) {
                throw $e;
            }

            $visibility = Visibility::PUBLIC;
        }

in StreamStatCommand.php

However, if the adapter just returns the default flysytems' FileAttributes object, which sets visiblity to null (as f.e. spaties dropboxadapter does, a bug in Flysystem will give a TypeError since the visibility function should not return null but a string (reported there). The TypeError is not caught by the above catch. It is probably a good idea to accept a wider range of throwables since any adapter may find their own way of letting know that visibility isn't a thing.

fseek(): supplied resource is not a valid stream resource

image

Currently on a migration and using this library. I need to fork it though and add the following line for it to work:

StreamWrapper::109

                if (is_resource($this->current->handle)) {
                    fseek($this->current->handle, $currentPosition);
                }

I don't know why this is needed there, but everything works fine afterwards. Maybe it is because the Stream is being rewinded after Flysystems writeStream.
image

image

They also check weather or not the resource is seekable. That might be the right check.

is_readable is not working

We try to send E-Mails with Symfony's Mailer over async Messenger component.

The App creates attachments and triggers the SendMailMessage. We use the flysystem-stream-wrapper to store those attachments on a secure S3 storage.

It fails with Path [REDACTED] is not readable. in DataPart.php (Symfony Mailer Component)
image

Locally, it is somehow not a problem. So I thought it could have been something about the locking component, but changing the lock to in-memory and TTL to 1 second did not resolve the issue.

So, I did a lot of debugging and printing and here are the results:
image

{
  attachment: {0}
  fileInfo: {}
  fileName: "[REDACTED]"
  isFile: true
  isReadable: false
  path: "gcloud://"
  pathInfo: {}
  pathname: "gcloud://[REDACTED]"
  realPath: false
  stat: {
    0: 0
    1: 0
    10: 1656327883
    11: -1
    12: -1
    2: 33152
    3: 0
    4: 0
    5: 65534
    6: 0
    7: 36798
    8: 1656327883
    9: 1656327883
    atime: 1656327883
    blksize: -1
    blocks: -1
    ctime: 1656327883
    dev: 0
    gid: 65534
    ino: 0
    mode: 33152
    mtime: 1656327883
    nlink: 0
    rdev: 0
    size: 36798
    uid: 0
  }
}

It seems to fail at is_readable, which returns false. So I tried to check the mode using stat, as I figured out with a bit of php source code reading that it seems to use that.

Ignoring the is_readable, I tried to open the file to make sure the FlySystem is setup correctly:
image

And it actually works:
image

So the bug would seem to be, that the StreamStatCommand is not setting the right mode?

`is_writable` returns false for created directories

I'm running into issues with the following code (minimal reproduction - my actual use case involves a third party lib)

FlysystemStreamWrapper::register(
  "fly",
  new Filesystem(new LocalFilesystemAdapter("./")),
);
mkdir("fly://my-dir", 0666, true);
is_writable("fly://my-dir");

Expected
is_writable should return true

Actual
is_writable returns false

Research
When a new directory is created inside the FlysystemStreamWrapper, it seems as if permissions are set to 755, meaning only the owner may write to the directory. Calling fileowner("fly://my-dir") returns 0 which is equivalent to the root user on my system - i.e. not my php user. This appears to cause php to believe it does not have write access to "my-dir".

Forcing a write despite is_writable proves that the directory is, in fact, writable.

Problems

  1. FlysystemStreamWrapper does not create directories with the requested access rights
  2. Created directories erroneously report owner 0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.