Skip to content

Commit 51c38d8

Browse files
committed
fix
1 parent e015bec commit 51c38d8

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

os/src/ZipOps.scala

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,17 +155,23 @@ object zip {
155155

156156
val fis = if (os.isFile(file)) Some(os.read.inputStream(file)) else None
157157

158-
val path = if (os.isDir(file)) sub.toString + "/" else sub.toString
159-
try makeZipEntry0(path, fis, mtimeOpt, zipOut)
158+
try makeZipEntry0(sub, fis, mtimeOpt, zipOut)
160159
finally fis.foreach(_.close())
161160
}
162161

163162
private def makeZipEntry0(
164-
path: String,
163+
sub: os.SubPath,
165164
is: Option[java.io.InputStream],
166165
preserveMtimes: Option[Long],
167166
zipOut: ZipOutputStream
168167
) = {
168+
val path = is match {
169+
// for folder
170+
case None => sub.toString + "/"
171+
// for file
172+
case Some(_) => sub.toString
173+
}
174+
169175
val zipEntry = new ZipEntry(path)
170176

171177
preserveMtimes match {

0 commit comments

Comments
 (0)