Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-workhorse
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
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-workhorse
Commits
bb374fbd
Commit
bb374fbd
authored
Jan 26, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extend specs for metadata, improve internal loop
parent
d76b7599
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
13 deletions
+16
-13
internal/zipartifacts/metadata.go
internal/zipartifacts/metadata.go
+4
-2
internal/zipartifacts/metadata_test.go
internal/zipartifacts/metadata_test.go
+12
-11
No files found.
internal/zipartifacts/metadata.go
View file @
bb374fbd
...
...
@@ -79,9 +79,11 @@ func generateZipMetadata(output io.Writer, archive *zip.Reader) error {
for
d
:=
path
.
Dir
(
entry
.
Name
);
d
!=
"."
&&
d
!=
"/"
;
d
=
path
.
Dir
(
d
)
{
entryDir
:=
d
+
"/"
if
_
,
ok
:=
zipMap
[
entryDir
];
!
ok
{
zipMap
[
entryDir
]
=
nil
// If entryDir is already in the zipMap then so are all its parent directories
if
_
,
ok
:=
zipMap
[
entryDir
];
ok
{
break
}
zipMap
[
entryDir
]
=
nil
}
}
...
...
internal/zipartifacts/metadata_test.go
View file @
bb374fbd
...
...
@@ -13,28 +13,29 @@ func TestMissingMetadataEntries(t *testing.T) {
archive
:=
zip
.
NewWriter
(
&
zipBuffer
)
firstFile
,
err
:=
archive
.
Create
(
"file1"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
fmt
.
Fprint
(
firstFile
,
"test12"
)
files
:=
[]
string
{
"file1"
,
"some/file/dir/file2"
,
"../../test12/test"
,
"/usr/bin/test"
,
`c:\windows\win32.exe`
,
`c:/windows/win.dll`
,
"./f/asd"
,
"/"
}
secondFile
,
err
:=
archive
.
Create
(
"some/file/dir/file2"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
for
_
,
file
:=
range
files
{
archiveFile
,
err
:=
archive
.
Create
(
file
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
fmt
.
Fprint
(
archiveFile
,
file
)
}
fmt
.
Fprint
(
secondFile
,
"test125678"
)
archive
.
Close
()
zipReader
:=
bytes
.
NewReader
(
zipBuffer
.
Bytes
())
zipArchiveReader
,
_
:=
zip
.
NewReader
(
zipReader
,
int64
(
binary
.
Size
(
zipBuffer
.
Bytes
())))
err
=
generateZipMetadata
(
&
metaBuffer
,
zipArchiveReader
)
if
err
:=
generateZipMetadata
(
&
metaBuffer
,
zipArchiveReader
);
err
!=
nil
{
t
.
Fatal
(
"zipartifacts: generateZipMetadata failed"
,
err
)
}
paths
:=
[]
string
{
"file1"
,
"some/"
,
"some/file/"
,
"some/file/dir"
,
"some/file/dir/file2"
}
for
_
,
path
:=
range
paths
{
if
!
bytes
.
Contains
(
metaBuffer
.
Bytes
(),
[]
byte
(
path
))
{
t
.
Fatal
f
(
"zipartifacts: metadata for path %s not found!"
,
path
)
t
.
Fatal
(
"zipartifacts: metadata for path"
,
path
,
"not found"
)
}
}
}
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