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
30d9d589
Commit
30d9d589
authored
Jul 03, 2020
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Eagerly delete anonymous tempfiles
parent
71cd15d1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
12 deletions
+23
-12
internal/lsif_transformer/parser/cache.go
internal/lsif_transformer/parser/cache.go
+5
-4
internal/lsif_transformer/parser/hovers.go
internal/lsif_transformer/parser/hovers.go
+4
-1
internal/lsif_transformer/parser/parser.go
internal/lsif_transformer/parser/parser.go
+14
-7
No files found.
internal/lsif_transformer/parser/cache.go
View file @
30d9d589
...
...
@@ -21,6 +21,10 @@ func newCache(tempDir, filename string, data interface{}) (*cache, error) {
return
nil
,
err
}
if
err
:=
os
.
Remove
(
f
.
Name
());
err
!=
nil
{
return
nil
,
err
}
return
&
cache
{
file
:
f
,
chunkSize
:
int64
(
binary
.
Size
(
data
))},
nil
}
...
...
@@ -41,10 +45,7 @@ func (c *cache) Entry(id Id, data interface{}) error {
}
func
(
c
*
cache
)
Close
()
error
{
return
combineErrors
(
c
.
file
.
Close
(),
os
.
Remove
(
c
.
file
.
Name
()),
)
return
c
.
file
.
Close
()
}
func
(
c
*
cache
)
setOffset
(
id
Id
)
error
{
...
...
internal/lsif_transformer/parser/hovers.go
View file @
30d9d589
...
...
@@ -42,6 +42,10 @@ func NewHovers(tempDir string) (*Hovers, error) {
return
nil
,
err
}
if
err
:=
os
.
Remove
(
file
.
Name
());
err
!=
nil
{
return
nil
,
err
}
offsets
,
err
:=
newCache
(
tempDir
,
"hovers-indexes"
,
Offset
{})
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -91,7 +95,6 @@ func (h *Hovers) For(refId Id) json.RawMessage {
func
(
h
*
Hovers
)
Close
()
error
{
return
combineErrors
(
h
.
File
.
Close
(),
os
.
Remove
(
h
.
File
.
Name
()),
h
.
Offsets
.
Close
(),
)
}
...
...
internal/lsif_transformer/parser/parser.go
View file @
30d9d589
...
...
@@ -68,21 +68,28 @@ func openZipReader(reader io.Reader, tempDir string) (io.Reader, error) {
if
err
!=
nil
{
return
nil
,
err
}
defer
os
.
Remove
(
tempFile
.
Name
())
if
_
,
err
:=
io
.
Copy
(
tempFile
,
reader
);
err
!=
nil
{
if
err
:=
os
.
Remove
(
tempFile
.
Name
()
);
err
!=
nil
{
return
nil
,
err
}
zr
,
err
:=
zip
.
OpenReader
(
tempFile
.
Name
()
)
size
,
err
:=
io
.
Copy
(
tempFile
,
reader
)
if
err
!=
nil
{
return
nil
,
err
}
f
:=
zr
.
File
[
0
]
if
f
==
nil
{
return
nil
,
errors
.
New
(
"invalid zip file"
)
if
_
,
err
:=
tempFile
.
Seek
(
0
,
io
.
SeekStart
);
err
!=
nil
{
return
nil
,
err
}
zr
,
err
:=
zip
.
NewReader
(
tempFile
,
size
)
if
err
!=
nil
{
return
nil
,
err
}
if
len
(
zr
.
File
)
==
0
{
return
nil
,
errors
.
New
(
"empty zip file"
)
}
return
f
.
Open
()
return
zr
.
File
[
0
]
.
Open
()
}
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