thephpleague / flysystem-rackspace

Flysystem Adapter for Rackspace
37 stars 28 forks source link

readStream needs to be rewound before using #19

Closed PatrickRose closed 8 years ago

PatrickRose commented 8 years ago

I've just spotted an inconsistency between the Local adapter and the Rackspace one:


$localFilesystem = new Filesystem(new Local('/path/to/dir'));
$localFilesystem->write('some/file', 'Hello');
$localStream = $localFilesystem->readStream('some/file');

echo stream_get_contents($localStream); // outputs Hello

$rackspaceFilesystem = new Filesystem(new RackspaceAdapter($container));
$rackspaceFilesystem->write('some/file', 'Hello');
$rackspaceStream = $rackspaceFilesystem->readStream('some/file');

echo stream_get_contents($rackspaceStream); // outputs an empty string

I think the stream should always be at the beginning of the file, or it's difficult to just change the adapter and get the same result.

frankdejonge commented 8 years ago

This is very odd, the stream is rewinded and detached. I'll push a commit which uses rackspace's rewind method, let's see if that changes anything, this is not really coverable by tests unfortunately.

PatrickRose commented 8 years ago

I've just got an integration test that does the above to verify it. I had to call rewind on it for it to work.

frankdejonge commented 8 years ago

@PatrickRose I've just pushed a commit, could you check dev-master?

PatrickRose commented 8 years ago

Hang on a sec, it looks like I'm on an old version of this adapter and didn't spot #13 (because I'm an idiot). Sorry for noise!

frankdejonge commented 8 years ago

@PatrickRose thanks for getting back about this.