Skip to content

Commit b63a0d4

Browse files
authored
fix issue of downloading and using github sourced migration files of … (#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
1 parent 8ec0422 commit b63a0d4

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

source/github/github.go

+4-16
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ func (g *Github) ReadUp(version uint) (r io.ReadCloser, identifier string, err e
178178
g.ensureFields()
179179

180180
if m, ok := g.migrations.Up(version); ok {
181-
file, _, _, err := g.client.Repositories.GetContents(
181+
r, _, err := g.client.Repositories.DownloadContents(
182182
context.Background(),
183183
g.config.Owner,
184184
g.config.Repo,
@@ -189,13 +189,7 @@ func (g *Github) ReadUp(version uint) (r io.ReadCloser, identifier string, err e
189189
if err != nil {
190190
return nil, "", err
191191
}
192-
if file != nil {
193-
r, err := file.GetContent()
194-
if err != nil {
195-
return nil, "", err
196-
}
197-
return io.NopCloser(strings.NewReader(r)), m.Identifier, nil
198-
}
192+
return r, m.Identifier, nil
199193
}
200194
return nil, "", &os.PathError{Op: fmt.Sprintf("read version %v", version), Path: g.config.Path, Err: os.ErrNotExist}
201195
}
@@ -204,7 +198,7 @@ func (g *Github) ReadDown(version uint) (r io.ReadCloser, identifier string, err
204198
g.ensureFields()
205199

206200
if m, ok := g.migrations.Down(version); ok {
207-
file, _, _, err := g.client.Repositories.GetContents(
201+
r, _, err := g.client.Repositories.DownloadContents(
208202
context.Background(),
209203
g.config.Owner,
210204
g.config.Repo,
@@ -215,13 +209,7 @@ func (g *Github) ReadDown(version uint) (r io.ReadCloser, identifier string, err
215209
if err != nil {
216210
return nil, "", err
217211
}
218-
if file != nil {
219-
r, err := file.GetContent()
220-
if err != nil {
221-
return nil, "", err
222-
}
223-
return io.NopCloser(strings.NewReader(r)), m.Identifier, nil
224-
}
212+
return r, m.Identifier, nil
225213
}
226214
return nil, "", &os.PathError{Op: fmt.Sprintf("read version %v", version), Path: g.config.Path, Err: os.ErrNotExist}
227215
}

0 commit comments

Comments
 (0)