-
Notifications
You must be signed in to change notification settings - Fork 70
Support pre-compressed uploads in code-intel upload, deprecate LSIF #1146
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
f9592c2
Support GZIP-compressed SCIP files
antonsviridov-src c674dec
exhaustive if
antonsviridov-src 1fe4a09
add vendoring note
antonsviridov-src 33aba37
fix lints
antonsviridov-src 2af6d53
restore error handling
antonsviridov-src 8c10ba7
Build src-cli from scratch in SCIP upload workflow
antonsviridov-src 66aae07
Try fetching the whole repo?
antonsviridov-src 895354d
Disable VCS stamping?
antonsviridov-src 9652806
Move steps around
antonsviridov-src 30c9f71
PR comments
antonsviridov-src 99be1c7
Align vendored code closer to the source
antonsviridov-src dae3546
remove CLI flag
antonsviridov-src File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "context" | ||
| "os" | ||
|
|
||
| "github.com/sourcegraph/sourcegraph/lib/codeintel/upload" | ||
| "github.com/sourcegraph/sourcegraph/lib/output" | ||
| ) | ||
|
|
||
| func UploadUncompressedIndex(ctx context.Context, filename string, httpClient upload.Client, opts upload.UploadOptions) (int, error) { | ||
| originalReader, originalSize, err := openFileAndGetSize(filename) | ||
| if err != nil { | ||
| return 0, err | ||
| } | ||
| defer func() { | ||
| _ = originalReader.Close() | ||
| }() | ||
|
|
||
| bars := []output.ProgressBar{{Label: "Compressing", Max: 1.0}} | ||
| progress, _, cleanup := logProgress( | ||
| opts.Output, | ||
| bars, | ||
| "Index compressed", | ||
| "Failed to compress index", | ||
| ) | ||
|
|
||
| compressedFile, err := compressReaderToDisk(originalReader, originalSize, progress) | ||
| if err != nil { | ||
| cleanup(err) | ||
| return 0, err | ||
| } | ||
| defer func() { | ||
| _ = os.Remove(compressedFile) | ||
| }() | ||
|
|
||
| compressedSize, err := getFileSize(compressedFile) | ||
| if err != nil { | ||
| cleanup(err) | ||
| return 0, err | ||
| } | ||
|
|
||
| cleanup(nil) | ||
|
|
||
| if opts.Output != nil { | ||
| opts.Output.WriteLine(output.Linef( | ||
| output.EmojiLightbulb, | ||
| output.StyleItalic, | ||
| "Indexed compressed (%.2fMB -> %.2fMB).", | ||
| float64(originalSize)/1000/1000, | ||
| float64(compressedSize)/1000/1000, | ||
| )) | ||
| } | ||
|
|
||
| return UploadCompressedIndex(ctx, compressedFile, httpClient, opts, originalSize) | ||
| } | ||
|
|
||
| func UploadCompressedIndex(ctx context.Context, compressedFile string, httpClient upload.Client, opts upload.UploadOptions, uncompressedSize int64) (int, error) { | ||
| compressedReader, compressedSize, err := openFileAndGetSize(compressedFile) | ||
| if err != nil { | ||
| // cleanup(err) | ||
| return 0, err | ||
| } | ||
| defer func() { | ||
| _ = compressedReader.Close() | ||
| }() | ||
|
|
||
| if compressedSize <= opts.MaxPayloadSizeBytes { | ||
| return uploadIndex(ctx, httpClient, opts, compressedReader, compressedSize, uncompressedSize) | ||
| } | ||
|
|
||
| return uploadMultipartIndex(ctx, httpClient, opts, compressedReader, compressedSize, uncompressedSize) | ||
| } | ||
|
|
||
| func getFileSize(filename string) (int64, error) { | ||
| fileInfo, err := os.Stat(filename) | ||
| if err != nil { | ||
| return 1, err | ||
| } | ||
|
|
||
| return fileInfo.Size(), nil | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.