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

Redundant API calls in Object.Attrs, elsewhere #37

Open
kurin opened this issue Feb 16, 2018 · 7 comments
Open

Redundant API calls in Object.Attrs, elsewhere #37

kurin opened this issue Feb 16, 2018 · 7 comments

Comments

@kurin
Copy link
Owner

kurin commented Feb 16, 2018

restic/restic#1383 is showing a lot of class B transactions.

Restic calls Attrs to ensure that an object doesn't exist before uploading it. This calls object.ensure, which populates the object ID and name, and then (on objects that exist) getFileInfo, to populate the Info field. This probably isn't necessary, although I'm not sure why object.ensure went from getFileInfo to downloadFileByName in the first place in 8b44fc9.

@kurin
Copy link
Owner Author

kurin commented Feb 16, 2018

Oh I see, getFileInfo can't be called without the fileId, which we don't have without another call first.

However, downloadFileByName returns the X-Bz-Info-* headers, so we can populate object info from that.

@kurin
Copy link
Owner Author

kurin commented Feb 16, 2018

This is actually trickier than it looks. Not all the information (upload timestamp, status, specifically) is available from downloadFileByName. But I don't want to open with getFileInfo because identifying a 404 shouldn't be a class C op.

@kurin
Copy link
Owner Author

kurin commented Feb 16, 2018

(which is what list_files is, which is the only other way to get at the file ID when we don't already know it)

kurin added a commit that referenced this issue Feb 17, 2018
kurin added a commit that referenced this issue Feb 17, 2018
@nicolas17
Copy link

You no longer need to ensure a file doesn't exist before uploading it (and that's impossible to do without race conditions anyway). Is this ticket still valid?

@kurin
Copy link
Owner Author

kurin commented Feb 28, 2018

That's an implementation detail for restic; B2 never required that test.

This bug isn't so much about removing that test as it is determining that I'm not making two calls when one would suffice within blazer. For example, the Reader used to require a b2_get_file_info call to get the total object size before downloading it, but that was changed in #12. There may be others.

@nicolas17
Copy link

Bah, I got confused and thought this ticket was in the restic repo 🙈

@kurin
Copy link
Owner Author

kurin commented Feb 28, 2018

Hah, no worries.

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

2 participants