Skip to content

Commit 3561d0b

Browse files
tsurovecmuuki88
andauthored
Zip helper adds directories (#1525)
* Zip helper adds directories * ZipHelpSpec rm obsolete comment --------- Co-authored-by: Muki Seiler <muuki88@users.noreply.github.com>
1 parent 79ccdf6 commit 3561d0b

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

src/main/scala/com/typesafe/sbt/packager/universal/ZipHelper.scala

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,17 +109,19 @@ object ZipHelper {
109109
val outputDir = outputFile.getParentFile
110110
IO createDirectory outputDir
111111
withZipOutput(outputFile) { output =>
112-
for (FileMapping(file, name, mode) <- sources; if !file.isDirectory) {
112+
for (FileMapping(file, name, mode) <- sources) {
113113
val entry = new ZipArchiveEntry(file, normalizePath(name))
114114
// Now check to see if we have permissions for this sucker.
115115
mode foreach (entry.setUnixMode)
116116
output putArchiveEntry entry
117-
val fis = new java.io.FileInputStream(file)
118-
try try
119-
// TODO - Write file into output?
120-
IOUtils.copy(fis, output)
121-
finally output.closeArchiveEntry()
122-
finally fis.close()
117+
118+
try if (file.isFile) {
119+
val fis = new java.io.FileInputStream(file)
120+
try
121+
// TODO - Write file into output?
122+
IOUtils.copy(fis, output)
123+
finally fis.close()
124+
} finally output.closeArchiveEntry()
123125
}
124126
}
125127
}

src/test/scala/com/typesafe/sbt/packager/universal/ZipHelperSpec.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ class ZipHelperSpec extends WordSpec with Matchers with BeforeAndAfterEach with
3131
zipSingleFile(ZipHelper.zip)
3232
}
3333

34-
// ignores empty directories
35-
"create a zip with nested directories" taggedAs (LinuxTag, WindowsTag) ignore {
34+
"create a zip with nested directories" taggedAs (LinuxTag, WindowsTag) in {
3635
zipNestedFile(ZipHelper.zip)
3736
}
3837

0 commit comments

Comments
 (0)