Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cursor offset doesn't update when using upload_session_append_v2 #24

Closed
Aupajo opened this issue Jun 20, 2017 · 0 comments
Closed

Cursor offset doesn't update when using upload_session_append_v2 #24

Aupajo opened this issue Jun 20, 2017 · 0 comments

Comments

@Aupajo
Copy link
Contributor

Aupajo commented Jun 20, 2017

I've been experimenting with the upload session API, and I think I've found a bug not covered by the current test cases.

commit = DropboxApi::Metadata::CommitInfo.new({
  "path" => "/test.txt",
  "mode" => :add
})

# Upload the first three bytes
cursor = client.upload_session_start('abc')

# Cursor offset has been correctly set to 3 at this point
expect(cursor.offset).to eq(3)

# Upload the second three bytes
client.upload_session_append_v2(cursor, 'def')

# Cursor offset *should* be set to 6 at this point, but remains 3
# expect(cursor.offset).to eq(6)

# Attempt to commit the upload
client.upload_session_finish(cursor, commit)

This raises an error:

DropboxApi::Errors::UploadSessionOffsetError:
  lookup_failed/incorrect_offset/..., correct offset: 6

This happens because the offset of the cursor never changes from 3 to 6 after the call to upload_session_append_v2.

This hack will cause the test to pass:

cursor = client.upload_session_start('abc')
client.upload_session_append_v2(cursor, 'def')

# Manually update the offset
cursor.instance_variable_set(:@offset, 6)

client.upload_session_finish(cursor, commit)

There are test cases covering upload_session_append_v2 and upload_session_finish, but never the two together, which would otherwise reveal this problem.

I believe the correct behaviour is to have upload_session_append_v2 update the cursors offset after a successful request, and I'm working on a fix for this at the moment – let me know if you have any thoughts on this in the meantime.

@Jesus Jesus closed this as completed in #25 Jun 30, 2017
Jesus added a commit that referenced this issue Jun 30, 2017
…ppending

Update UploadSessionCursor offset when appending uploads (fixes #24)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant