Skip to content

Commit

Permalink
fix issue of downloading and using github sourced migration files of … (
Browse files Browse the repository at this point in the history
#900)

* fix issue of downloading and using github sourced migration files of 100MB >=1Mb (which previously failed to download due to their size and the api call performed) by preferring the go-github client library method 'DownloadContents' for such operations (which doesn't have the same limitation)

* empty commit & push to trigger ci
  • Loading branch information
gfcroft committed Mar 25, 2023
1 parent 8ec0422 commit b63a0d4
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions source/github/github.go
Expand Up @@ -178,7 +178,7 @@ func (g *Github) ReadUp(version uint) (r io.ReadCloser, identifier string, err e
g.ensureFields()

if m, ok := g.migrations.Up(version); ok {
file, _, _, err := g.client.Repositories.GetContents(
r, _, err := g.client.Repositories.DownloadContents(
context.Background(),
g.config.Owner,
g.config.Repo,
Expand All @@ -189,13 +189,7 @@ func (g *Github) ReadUp(version uint) (r io.ReadCloser, identifier string, err e
if err != nil {
return nil, "", err
}
if file != nil {
r, err := file.GetContent()
if err != nil {
return nil, "", err
}
return io.NopCloser(strings.NewReader(r)), m.Identifier, nil
}
return r, m.Identifier, nil
}
return nil, "", &os.PathError{Op: fmt.Sprintf("read version %v", version), Path: g.config.Path, Err: os.ErrNotExist}
}
Expand All @@ -204,7 +198,7 @@ func (g *Github) ReadDown(version uint) (r io.ReadCloser, identifier string, err
g.ensureFields()

if m, ok := g.migrations.Down(version); ok {
file, _, _, err := g.client.Repositories.GetContents(
r, _, err := g.client.Repositories.DownloadContents(
context.Background(),
g.config.Owner,
g.config.Repo,
Expand All @@ -215,13 +209,7 @@ func (g *Github) ReadDown(version uint) (r io.ReadCloser, identifier string, err
if err != nil {
return nil, "", err
}
if file != nil {
r, err := file.GetContent()
if err != nil {
return nil, "", err
}
return io.NopCloser(strings.NewReader(r)), m.Identifier, nil
}
return r, m.Identifier, nil
}
return nil, "", &os.PathError{Op: fmt.Sprintf("read version %v", version), Path: g.config.Path, Err: os.ErrNotExist}
}

0 comments on commit b63a0d4

Please sign in to comment.