Skip to content

Check server for objects before failing push because local is missing - #581

Merged
technoweenie merged 8 commits into
git-lfs:masterfrom
sinbad:pre-push-missing-local-present-server
Aug 14, 2015
Merged

technoweenie merged 8 commits into
git-lfs:masterfrom
sinbad:pre-push-missing-local-present-server

Conversation

@sinbad

@sinbad sinbad commented Aug 12, 2015

Copy link
Copy Markdown
Contributor

The local client doesn't have all the LFS objects so it's perfectly valid to push commits which reference objects that don't exist, so long as the server already has them. This could occur when deleting files and pushing new branches (#564) but is increasingly likely as fetch & prune functionality is introduced.

So now we perform a pre-check and any locally missing files are checked on the server. To gain the benefit of the existing parallelism and batching API this required adding a new type of transferable which only checks for download, and doesn't actually do it - instead the fact that the transfer would go ahead is used as an indicator that this oid can be skipped when it comes to push & therefore not cause the process to fail.

After merging this PR it's safe to merge #573 (which deliberately doesn't download all LFS objects).

sinbad added 6 commits August 11, 2015 18:07
…iable in batch mode

In batch mode you don't get an error from a missing Check(), you just get
a lack of download link (get an upload link instead). Therefore the only
reliable way to judge whether Check() worked is to check the transfer chan.

Also add tests for batch mode to prove this works
@rubyist

rubyist commented Aug 12, 2015

Copy link
Copy Markdown
Contributor

Looks good to me 👍

What do folks thing about embedding a Downloadable in Checkable and avoiding repeating all the methods? e.g.

type Checkable struct {
    Pointer *WrappedPointer
    object  *objectResource
    *Downloadable
}

func NewCheckable(p *WrappedPointer) *Checkable {
    return &Checkable{Pointer: p, Downloadable: NewDownloadable(p)}
}

func (d *Checkable) Transfer(cb CopyCallback) *WrappedError {
    // just report completion of check but don't do anything
    cb(d.Size(), d.Size(), int(d.Size()))
    return nil
}

While we don't technically need NewCheckQueue, I think I'm OK with it because it helps make the intent clear.

@sinbad

sinbad commented Aug 12, 2015

Copy link
Copy Markdown
Contributor Author

What do folks thing about embedding a Downloadable in Checkable and avoiding repeating all the methods?

That's cool but feels a bit funky having Checkable include a more specific type. I think it would make more sense conceptually to do the reverse and embed a Checkable in Downloadable?

@technoweenie

Copy link
Copy Markdown
Contributor

I think it would make more sense conceptually to do the reverse and embed a Checkable in Downloadable?

It depends how you look at it. Is Downloadable embedding Checkable to add new functionality, or is Checkable embedding Downloadable to disable functionality?

I think it makes sense for both Downloadable and Uploadable to embed a Checkable.

@rubyist

rubyist commented Aug 12, 2015

Copy link
Copy Markdown
Contributor

I think Checkable as the base makes the most sense. I'm also not opposed to keeping it as it is, just wondering aloud kind of thing.

Comment thread test/cmd/lfstest-gitserver.go Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This duplication seems unnecessary. Can we get away with changing the action key from "upload" to "download" based on the bool return value from largeObjects.Get()?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Renamed Checkable to DownloadCheckable because it only applies to download,
upload checks differently and uses different struct fields. Incorporated
with download_queue.go since code is now smaller & common.
@sinbad

sinbad commented Aug 13, 2015

Copy link
Copy Markdown
Contributor Author

I think Checkable as the base makes the most sense. I'm also not opposed to keeping it as it is, just wondering aloud kind of thing.

Yeah this was a good point to make. On reflection I've renamed it DownloadCheckable because the check is specific to download, and the upload check is different (and Uploadable uses a different field structure so there's no re-use). Downloadable now just embeds DownloadCheckable and overrides Transfer().

@sinbad

sinbad commented Aug 13, 2015

Copy link
Copy Markdown
Contributor Author

Hrm, random failure in checkout test on Travis when it works fine here...

@sinbad

sinbad commented Aug 13, 2015

Copy link
Copy Markdown
Contributor Author

I discovered I can re-run the Travis test on my own fork (I can't here) and it passed at the same commit. https://travis-ci.org/sinbad/git-lfs/builds/75401728

@sinbad

sinbad commented Aug 14, 2015

Copy link
Copy Markdown
Contributor Author

Any chance you can re-run the Travis check on this PR please? I think it's bogus (see previous comment, same commit tested fine in my fork).

@rubyist

rubyist commented Aug 14, 2015

Copy link
Copy Markdown
Contributor

Passed!

technoweenie added a commit that referenced this pull request Aug 14, 2015
…rver

Check server for objects before failing push because local is missing
@technoweenie
technoweenie merged commit 179224c into git-lfs:master Aug 14, 2015
@sinbad
sinbad deleted the pre-push-missing-local-present-server branch September 1, 2015 14:49
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.

3 participants