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
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-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
Show 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 {
...
@@ -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
)
{
for
d
:=
path
.
Dir
(
entry
.
Name
);
d
!=
"."
&&
d
!=
"/"
;
d
=
path
.
Dir
(
d
)
{
entryDir
:=
d
+
"/"
entryDir
:=
d
+
"/"
if
_
,
ok
:=
zipMap
[
entryDir
];
!
ok
{
// If entryDir is already in the zipMap then so are all its parent directories
zipMap
[
entryDir
]
=
nil
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) {
...
@@ -13,28 +13,29 @@ func TestMissingMetadataEntries(t *testing.T) {
archive
:=
zip
.
NewWriter
(
&
zipBuffer
)
archive
:=
zip
.
NewWriter
(
&
zipBuffer
)
firstFile
,
err
:=
archive
.
Create
(
"file1"
)
files
:=
[]
string
{
"file1"
,
"some/file/dir/file2"
,
"../../test12/test"
,
if
err
!=
nil
{
"/usr/bin/test"
,
`c:\windows\win32.exe`
,
`c:/windows/win.dll`
,
"./f/asd"
,
"/"
}
t
.
Fatal
(
err
)
}
fmt
.
Fprint
(
firstFile
,
"test12"
)
secondFile
,
err
:=
archive
.
Create
(
"some/file/dir/file2"
)
for
_
,
file
:=
range
files
{
archiveFile
,
err
:=
archive
.
Create
(
file
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
fmt
.
Fprint
(
secondFile
,
"test125678"
)
fmt
.
Fprint
(
archiveFile
,
file
)
}
archive
.
Close
()
archive
.
Close
()
zipReader
:=
bytes
.
NewReader
(
zipBuffer
.
Bytes
())
zipReader
:=
bytes
.
NewReader
(
zipBuffer
.
Bytes
())
zipArchiveReader
,
_
:=
zip
.
NewReader
(
zipReader
,
int64
(
binary
.
Size
(
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"
}
paths
:=
[]
string
{
"file1"
,
"some/"
,
"some/file/"
,
"some/file/dir"
,
"some/file/dir/file2"
}
for
_
,
path
:=
range
paths
{
for
_
,
path
:=
range
paths
{
if
!
bytes
.
Contains
(
metaBuffer
.
Bytes
(),
[]
byte
(
path
))
{
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