Commit d4ee3a82 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Revert break when traversing directories for zip entries

parent bb374fbd
......@@ -79,13 +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 entryDir is already in the zipMap then so are all its parent directories
if _, ok := zipMap[entryDir]; ok {
break
}
if _, ok := zipMap[entryDir]; !ok {
zipMap[entryDir] = nil
}
}
}
// Sort paths
sortedPaths := make([]string, 0, len(zipMap))
......
......@@ -13,7 +13,8 @@ func TestMissingMetadataEntries(t *testing.T) {
archive := zip.NewWriter(&zipBuffer)
files := []string{"file1", "some/file/dir/file2", "../../test12/test",
// non-POSIX paths are here just to test if we never enter infinite loop
files := []string{"file1", "some/file/dir/", "some/file/dir/file2", "../../test12/test",
"/usr/bin/test", `c:\windows\win32.exe`, `c:/windows/win.dll`, "./f/asd", "/"}
for _, file := range files {
......@@ -32,9 +33,9 @@ func TestMissingMetadataEntries(t *testing.T) {
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 {
if !bytes.Contains(metaBuffer.Bytes(), []byte(path)) {
if !bytes.Contains(metaBuffer.Bytes(), []byte(path+"\x00")) {
t.Fatal("zipartifacts: metadata for path", path, "not found")
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment