Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
58bef439
Commit
58bef439
authored
Jun 17, 2020
by
Igor Drozdov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Log errors if lsif parser failed to close
parent
44ac7536
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
74 additions
and
22 deletions
+74
-22
internal/lsif_transformer/parser/cache.go
internal/lsif_transformer/parser/cache.go
+4
-5
internal/lsif_transformer/parser/errors.go
internal/lsif_transformer/parser/errors.go
+30
-0
internal/lsif_transformer/parser/errors_test.go
internal/lsif_transformer/parser/errors_test.go
+26
-0
internal/lsif_transformer/parser/hovers.go
internal/lsif_transformer/parser/hovers.go
+5
-9
internal/lsif_transformer/parser/ranges.go
internal/lsif_transformer/parser/ranges.go
+4
-5
internal/upload/rewrite.go
internal/upload/rewrite.go
+5
-3
No files found.
internal/lsif_transformer/parser/cache.go
View file @
58bef439
...
...
@@ -41,11 +41,10 @@ func (c *cache) Entry(id Id, data interface{}) error {
}
func
(
c
*
cache
)
Close
()
error
{
if
err
:=
c
.
file
.
Close
();
err
!=
nil
{
return
err
}
return
os
.
Remove
(
c
.
file
.
Name
())
return
combineErrors
(
c
.
file
.
Close
(),
os
.
Remove
(
c
.
file
.
Name
()),
)
}
func
(
c
*
cache
)
setOffset
(
id
Id
)
error
{
...
...
internal/lsif_transformer/parser/errors.go
0 → 100644
View file @
58bef439
package
parser
import
(
"errors"
"strings"
)
func
combineErrors
(
errsOrNil
...
error
)
error
{
var
errs
[]
error
for
_
,
err
:=
range
errsOrNil
{
if
err
!=
nil
{
errs
=
append
(
errs
,
err
)
}
}
if
len
(
errs
)
==
0
{
return
nil
}
if
len
(
errs
)
==
1
{
return
errs
[
0
]
}
var
msgs
[]
string
for
_
,
err
:=
range
errs
{
msgs
=
append
(
msgs
,
err
.
Error
())
}
return
errors
.
New
(
strings
.
Join
(
msgs
,
"
\n
"
))
}
internal/lsif_transformer/parser/errors_test.go
0 → 100644
View file @
58bef439
package
parser
import
(
"errors"
"testing"
"github.com/stretchr/testify/require"
)
type
customErr
struct
{
err
string
}
func
(
e
customErr
)
Error
()
string
{
return
e
.
err
}
func
TestCombineErrors
(
t
*
testing
.
T
)
{
err
:=
combineErrors
(
nil
,
errors
.
New
(
"first"
),
nil
,
customErr
{
"second"
})
require
.
EqualError
(
t
,
err
,
"first
\n
second"
)
err
=
customErr
{
"custom error"
}
require
.
Equal
(
t
,
err
,
combineErrors
(
nil
,
err
,
nil
))
require
.
Nil
(
t
,
combineErrors
(
nil
,
nil
,
nil
))
}
internal/lsif_transformer/parser/hovers.go
View file @
58bef439
...
...
@@ -89,15 +89,11 @@ func (h *Hovers) For(refId Id) json.RawMessage {
}
func
(
h
*
Hovers
)
Close
()
error
{
if
err
:=
h
.
File
.
Close
();
err
!=
nil
{
return
err
}
if
err
:=
os
.
Remove
(
h
.
File
.
Name
());
err
!=
nil
{
return
err
}
return
h
.
Offsets
.
Close
()
return
combineErrors
(
h
.
File
.
Close
(),
os
.
Remove
(
h
.
File
.
Name
()),
h
.
Offsets
.
Close
(),
)
}
func
(
h
*
Hovers
)
addData
(
line
[]
byte
)
error
{
...
...
internal/lsif_transformer/parser/ranges.go
View file @
58bef439
...
...
@@ -120,11 +120,10 @@ func (r *Ranges) Serialize(f io.Writer, rangeIds []Id, docs map[Id]string) error
}
func
(
r
*
Ranges
)
Close
()
error
{
if
err
:=
r
.
Cache
.
Close
();
err
!=
nil
{
return
err
}
return
r
.
Hovers
.
Close
()
return
combineErrors
(
r
.
Cache
.
Close
(),
r
.
Hovers
.
Close
(),
)
}
func
(
r
*
Ranges
)
definitionPathFor
(
docs
map
[
Id
]
string
,
refId
Id
)
string
{
...
...
internal/upload/rewrite.go
View file @
58bef439
...
...
@@ -140,7 +140,7 @@ func (rew *rewriter) handleFilePart(ctx context.Context, name string, p *multipa
inputReader
=
p
}
inputReader
,
err
:=
rew
.
handleLsifUpload
(
inputReader
,
opts
.
LocalTempPath
)
inputReader
,
err
:=
rew
.
handleLsifUpload
(
ctx
,
inputReader
,
opts
.
LocalTempPath
,
filename
)
if
err
!=
nil
{
return
err
}
...
...
@@ -170,7 +170,7 @@ func (rew *rewriter) handleFilePart(ctx context.Context, name string, p *multipa
return
rew
.
filter
.
ProcessFile
(
ctx
,
name
,
fh
,
rew
.
writer
)
}
func
(
rew
*
rewriter
)
handleLsifUpload
(
reader
io
.
Reader
,
tempPath
string
)
(
io
.
Reader
,
error
)
{
func
(
rew
*
rewriter
)
handleLsifUpload
(
ctx
context
.
Context
,
reader
io
.
Reader
,
tempPath
,
filename
string
)
(
io
.
Reader
,
error
)
{
if
rew
.
preauth
.
ProcessLsif
{
p
,
err
:=
parser
.
NewParser
(
reader
,
tempPath
)
if
err
!=
nil
{
...
...
@@ -183,7 +183,9 @@ func (rew *rewriter) handleLsifUpload(reader io.Reader, tempPath string) (io.Rea
}
if
err
:=
p
.
Close
();
err
!=
nil
{
return
nil
,
err
log
.
WithContextFields
(
ctx
,
log
.
Fields
{
"filename"
:
filename
,
})
.
Print
(
"failed to close lsif parser: "
+
err
.
Error
())
}
return
z
,
nil
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment