Only write parent entries when entry is new
Previously, when writing a repackaged jar, an attempt to write all of an entry's parent directories would always be made, irrespective of whether or not the entry itself had already been written. This was inefficient as, due to the way that the jar is written, once an entry itself has been written, we know that all of its parent directories will also have been written. This commit updates the jar writer so that no attempt is made to write parent directory entries if the entry itself has already been written. Fixes gh-29175
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -265,8 +265,8 @@ public abstract class AbstractJarWriter implements LoaderClassesWriter {
|
||||
private void writeEntry(JarArchiveEntry entry, Library library, EntryWriter entryWriter,
|
||||
UnpackHandler unpackHandler) throws IOException {
|
||||
String name = entry.getName();
|
||||
writeParentDirectoryEntries(name);
|
||||
if (this.writtenEntries.add(name)) {
|
||||
writeParentDirectoryEntries(name);
|
||||
entry.setUnixMode(name.endsWith("/") ? UNIX_DIR_MODE : UNIX_FILE_MODE);
|
||||
entry.getGeneralPurposeBit().useUTF8ForNames(true);
|
||||
if (!entry.isDirectory() && entry.getSize() == -1) {
|
||||
|
||||
Reference in New Issue
Block a user