Skip to content

Range request fail with GDrive stream wrapper, stream lies about being seekable #22476

Closed

Description

@PVince81

Steps to reproduce

  1. Setup GDrive storage as "gdrive"
  2. Upload a small text file with known contents
  3. curl -X GET -H Range:bytes=2-5 'http://root:admin@localhost/owncloud/remote.php/webdav/gdrive/bacon.txt'

Expected behaviour

Returned bytes match

Actual behaviour

Returned bytes start at the beginning of the stream

Version

ownCloud 9.0 git master 9c12485

This happens because the stream lies about being seekable when doing this check: https://github.com/owncloud/3rdparty/blob/master/sabre/dav/lib/DAV/CorePlugin.php#L336

If you debug into that block and evaluate the stream's metadata, its "seekable" value is true.
However as soon as Sabre tries to do a fseek it will fail.

I suspect this might be due to our stream wrappers which do implement fseek. We might need to somehow patch the wrappers to properly forward the underlying stream metadata.

@icewind1991 @schiesbn

Activity

  1. added this to the milestone on Feb 17, 2016
  2. PVince81 commented on Feb 17, 2016

    @PVince81
    ContributorAuthor

    This breaks syncing when the sync client tries to resume downloading using range requests.

  3. PVince81 commented on Feb 17, 2016

    @PVince81
    ContributorAuthor
  4. PVince81 commented on Feb 17, 2016

    @PVince81
    ContributorAuthor

    If that doesn't work, then we might want to implement the "read and discard data up to the correct position" to simulate forward fseek. (which Sabre actually does already if we tell it that the stream is not seekable)

  5. PVince81 commented on Feb 17, 2016

    @PVince81
    ContributorAuthor

    Something to be fixed in the streams library icewind1991/Streams#2

  6. modified the milestones: , on Feb 23, 2016
  7. PVince81 commented on Feb 24, 2016

    @PVince81
    ContributorAuthor

    I did some research and didn't find any way to make the stream wrapper influence the return value of stream_get_meta_data. So I raised at ticket for Sabre DAV https://github.com/fruux/sabre-dav/issues/787 to revert to the old 2.1 behavior where it was actually checking the result of fseek

  8. PVince81 commented on Mar 9, 2016

    @PVince81
    ContributorAuthor

    fseek works for GDrive on OC 9.0.0 because we had to fix the download by adding an intermediary temporary file which is seekable.

    However, we still need the general solution for non-seekable stream.

  9. PVince81 commented on Mar 15, 2016

    @PVince81
    ContributorAuthor

    Note that in 9.0 this isn't an issue any more because of the GDrive workaround using a temporary file.

    So before applying the patch, let's find out which external storages support streaming and would suffer from the fseek issue.

    I suspect that Webdav/ownCloud external storages (and/or fed shares) might.

  10. PVince81 commented on Mar 15, 2016

    @PVince81
    ContributorAuthor

    Hmm, with federated shares, fseek seems to work fine. Weird, it's not supposed to work on network streams.

  11. PVince81 commented on Mar 15, 2016

    @PVince81
    ContributorAuthor

    AHA, it looks like doing a fopen() on http:// supports fseek, but https:// doesn't...

  12. PVince81 commented on Mar 15, 2016

    @PVince81
    ContributorAuthor

    Steps:

    1. Setup an OC instance with SSL/HTTPS
    2. Create a folder "test" with a file "bacon.txt" inside
    3. Create a link share for "test"
    4. Mount the link share on a local OC 9.0 / master as "test"
    5. curl -X GET -H Range:bytes=2-5 'http://admin:admin@localhost/owncloud/remote.php/webdav/gdrive/bacon.txt' (on the local instance)

    Expected: fseek worked, middle of the text returned
    Actual: start of the text returned

  13. PVince81 commented on Mar 15, 2016

    @PVince81
    ContributorAuthor

    Fix is here through library update: owncloud-archive/3rdparty#258

  14. guruz commented on Mar 22, 2016

    @guruz
    Contributor

    @atroxix is getting negative content lengths already from PROPFIND.
    Is this fixed with that PR too?

    owncloud/client#4573 (comment)

  15. PVince81 commented on Mar 23, 2016

    @PVince81
    ContributorAuthor

    No, negative content length is a different thing.

  16. lock commented on Aug 5, 2019

    @lock

    This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  17. locked as resolved and limited conversation to collaborators on Aug 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions