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

Fixed zombie objects creation in Batch API #91

Merged
merged 1 commit into from
Mar 19, 2020

Conversation

val-krylov
Copy link
Contributor

Was:

  1. "upload" response for the first attempt to "download" non-existing object.
  2. "download" + "upload" response for any consecutive attempt to "download" non-existing object.

how-to-reproduce.txt

Was:
1. "upload" response for the first attempt to "download" non-existing object.
2. "download" + "upload" response for any consecutive attempt to "download" non-existing object.
Copy link
Member

@bk2204 bk2204 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey,

Thanks for the patch. It took me some time to figure out what's going on since your commit message was quite brief, but I think I've figured it out (and annotated it below) and this is the right solution.

@@ -323,9 +323,21 @@ func (a *App) BatchHandler(w http.ResponseWriter, r *http.Request) {
}

// Object is not found
meta, err = a.metaStore.Put(object)
if err == nil {
responseObjects = append(responseObjects, a.Represent(object, meta, meta.Existing, true, useTus))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To annotate this for future readers, what's going on here is that if the object is not found, we currently store a stub entry and return an upload response. However, if we're attempting to download, there's no reason to create a stub, since the user didn't request that, and so we should produce a 404 response for this object instead.

Because the Put method returns meta.Existing set to true here, we produce both a download and an upload.

if bv.Operation == "upload" {
meta, err = a.metaStore.Put(object)
if err == nil {
responseObjects = append(responseObjects, a.Represent(object, meta, false, true, useTus))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here, we don't use meta.Existing because we know that either (a) the database entry did not previously exist or (b) it did, but the file didn't exist on disk and all we had was a stub in the database. In neither case is the entry valid for download, since there's no data to back it.

@bk2204 bk2204 merged commit bdfa657 into git-lfs:master Mar 19, 2020
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

Successfully merging this pull request may close these issues.

2 participants