Skip to content

Commit dc347a5

Browse files
committed
Rename arg
1 parent 86af317 commit dc347a5

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

os/src/ZipOps.scala

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ object zip {
4747
* @param preserveMtimes Whether to preserve modification times (mtimes) of the files.
4848
* @param deletePatterns A list of regular expression patterns to delete files from an existing ZIP archive before appending new ones.
4949
* @param compressionLevel number from 0-9, where 0 is no compression and 9 is best compression. Defaults to -1 (default compression).
50-
* @param perserveLinks Whether to store symbolic links as symbolic links instead of the referenced files. Default to false. Setting this to true has no effect when modifying a zip file in place.
50+
* @param followLinks Whether to store symbolic links as the referenced files. Default to true. Setting this to false has no effect when modifying a zip file in place.
5151
* @return The path to the created ZIP archive.
5252
*/
5353
def apply(
@@ -58,7 +58,7 @@ object zip {
5858
preserveMtimes: Boolean = false,
5959
deletePatterns: Seq[Regex] = List(),
6060
compressionLevel: Int = java.util.zip.Deflater.DEFAULT_COMPRESSION,
61-
preserveLinks: Boolean = false
61+
followLinks: Boolean = true
6262
): os.Path = {
6363
checker.value.onWrite(dest)
6464
// check read preemptively in case "dest" is created
@@ -99,7 +99,7 @@ object zip {
9999
includePatterns,
100100
preserveMtimes,
101101
compressionLevel,
102-
preserveLinks,
102+
followLinks,
103103
f
104104
)
105105
finally f.close()
@@ -141,7 +141,7 @@ object zip {
141141
includePatterns: Seq[Regex],
142142
preserveMtimes: Boolean,
143143
compressionLevel: Int,
144-
preserveLinks: Boolean,
144+
resolveLinks: Boolean,
145145
out: java.io.OutputStream
146146
): Unit = {
147147
val zipOut = new apache.ZipOutputStream(out)
@@ -152,7 +152,7 @@ object zip {
152152
sources,
153153
excludePatterns,
154154
includePatterns,
155-
(path, sub) => makeZipEntry(path, sub, preserveMtimes, preserveLinks, zipOut)
155+
(path, sub) => makeZipEntry(path, sub, preserveMtimes, resolveLinks, zipOut)
156156
)
157157
zipOut.finish()
158158
} finally {
@@ -191,7 +191,7 @@ object zip {
191191
file: os.Path,
192192
sub: os.SubPath,
193193
preserveMtimes: Boolean,
194-
preserveLinks: Boolean,
194+
followLinks: Boolean,
195195
zipOut: apache.ZipOutputStream
196196
) = {
197197
val name =
@@ -204,14 +204,14 @@ object zip {
204204

205205
if (!scala.util.Properties.isWin) {
206206
val mode = apache.PermissionUtils.modeFromPermissions(
207-
os.perms(file, followLinks = !preserveLinks).toSet(),
208-
toFileType(file, followLinks = !preserveLinks)
207+
os.perms(file, followLinks = followLinks).toSet(),
208+
toFileType(file, followLinks = followLinks)
209209
)
210210
zipEntry.setUnixMode(mode)
211211
}
212212

213213
val fis =
214-
if (preserveLinks && !scala.util.Properties.isWin && os.isLink(file))
214+
if (!followLinks && !scala.util.Properties.isWin && os.isLink(file))
215215
Some(new java.io.ByteArrayInputStream(os.readLink(file).toString().getBytes()))
216216
else if (os.isFile(file)) Some(os.read.inputStream(file))
217217
else None
@@ -233,7 +233,7 @@ object zip {
233233
* @param includePatterns A list of regular expression patterns to include files in the ZIP archive. Defaults to an empty list (includes all files).
234234
* @param preserveMtimes Whether to preserve modification times (mtimes) of the files.
235235
* @param compressionLevel number from 0-9, where 0 is no compression and 9 is best compression. Defaults to -1 (default compression).
236-
* @param perserveLinks Whether to store symbolic links as symbolic links instead of the referenced files. Default to false. Setting this to true has no effect when modifying a zip file in place.
236+
* @param followLinks Whether to store symbolic links as the referenced files. Default to true.
237237
* @return A geny.Writable object for writing the ZIP data.
238238
*/
239239
def stream(
@@ -242,7 +242,7 @@ object zip {
242242
includePatterns: Seq[Regex] = List(),
243243
preserveMtimes: Boolean = false,
244244
compressionLevel: Int = java.util.zip.Deflater.DEFAULT_COMPRESSION,
245-
preserveLinks: Boolean = false
245+
followLinks: Boolean = false
246246
): geny.Writable = {
247247
(outputStream: java.io.OutputStream) =>
248248
{
@@ -252,7 +252,7 @@ object zip {
252252
includePatterns,
253253
preserveMtimes,
254254
compressionLevel,
255-
preserveLinks,
255+
followLinks,
256256
outputStream
257257
)
258258
}

os/test/src/ZipOpTests.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ object ZipOpTests extends TestSuite {
261261
wd: os.Path,
262262
zipStream: Boolean = false,
263263
unzipStream: Boolean = false,
264-
preserveLinks: Boolean = false
264+
followLinks: Boolean = true
265265
) = {
266266
val zipFileName = "zipped.zip"
267267
val source = wd / "folder2"
@@ -275,14 +275,14 @@ object ZipOpTests extends TestSuite {
275275
if (zipStream) {
276276
os.write(
277277
wd / zipFileName,
278-
os.zip.stream(sources = List(source), preserveLinks = preserveLinks)
278+
os.zip.stream(sources = List(source), followLinks = followLinks)
279279
)
280280
wd / zipFileName
281281
} else {
282282
os.zip(
283283
dest = wd / zipFileName,
284284
sources = List(source),
285-
preserveLinks = preserveLinks
285+
followLinks = followLinks
286286
)
287287
}
288288

@@ -307,7 +307,7 @@ object ZipOpTests extends TestSuite {
307307

308308
test("zip") - prep { wd =>
309309
if (!scala.util.Properties.isWin) {
310-
val (source, unzipped, link) = prepare(wd, preserveLinks = false)
310+
val (source, unzipped, link) = prepare(wd, followLinks = true)
311311

312312
// test all files are there
313313
assert(walkRel(source).toSet == walkRel(unzipped).toSet)
@@ -325,7 +325,7 @@ object ZipOpTests extends TestSuite {
325325

326326
test("zipPreserveLinks") - prep { wd =>
327327
if (!scala.util.Properties.isWin) {
328-
val (source, unzipped, link) = prepare(wd, preserveLinks = true)
328+
val (source, unzipped, link) = prepare(wd, followLinks = false)
329329

330330
assert(walkRel(source).toSet == walkRel(unzipped).toSet)
331331
assert(os.walk.stream(source)
@@ -341,7 +341,7 @@ object ZipOpTests extends TestSuite {
341341

342342
test("zipStream") - prep { wd =>
343343
if (!scala.util.Properties.isWin) {
344-
val (source, unzipped, link) = prepare(wd, zipStream = true, preserveLinks = false)
344+
val (source, unzipped, link) = prepare(wd, zipStream = true, followLinks = true)
345345

346346
assert(walkRel(source).toSet == walkRel(unzipped).toSet)
347347
assert(os.walk.stream(source)
@@ -356,7 +356,7 @@ object ZipOpTests extends TestSuite {
356356

357357
test("zipStreamPreserveLinks") - prep { wd =>
358358
if (!scala.util.Properties.isWin) {
359-
val (source, unzipped, link) = prepare(wd, zipStream = true, preserveLinks = true)
359+
val (source, unzipped, link) = prepare(wd, zipStream = true, followLinks = false)
360360

361361
assert(walkRel(source).toSet == walkRel(unzipped).toSet)
362362
assert(os.walk.stream(source)
@@ -371,7 +371,7 @@ object ZipOpTests extends TestSuite {
371371

372372
test("unzipStreamWithLinks") - prep { wd =>
373373
if (!scala.util.Properties.isWin) {
374-
val (source, unzipped, link) = prepare(wd, unzipStream = true, preserveLinks = true)
374+
val (source, unzipped, link) = prepare(wd, unzipStream = true, followLinks = false)
375375

376376
assert(walkRel(source).toSet == walkRel(unzipped).toSet)
377377

@@ -383,7 +383,7 @@ object ZipOpTests extends TestSuite {
383383

384384
test("unzipStream") - prep { wd =>
385385
if (!scala.util.Properties.isWin) {
386-
val (source, unzipped, link) = prepare(wd, unzipStream = true, preserveLinks = false)
386+
val (source, unzipped, link) = prepare(wd, unzipStream = true, followLinks = true)
387387

388388
assert(walkRel(source).toSet == walkRel(unzipped).toSet)
389389

0 commit comments

Comments
 (0)