Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions src/main/java/me/itzg/helpers/curseforge/CurseForgeInstaller.java
Original file line number Diff line number Diff line change
Expand Up @@ -426,13 +426,15 @@ static class OverridesResult {
}

private OverridesResult applyOverrides(Path modpackZip, String overridesDir) throws IOException {
log.debug("Applying overrides from '{}' in zip file", overridesDir);

final String levelEntryName = findLevelEntryInOverrides(modpackZip, overridesDir);
final String levelEntryNamePrefix = levelEntryName != null ? levelEntryName+"/" : null;

final boolean worldOutputDirExists = levelEntryName != null &&
Files.exists(outputDir.resolve(levelEntryName));

log.debug("Found level entry='{}' in modpack overrides and worldOutputDirExists={}",
log.debug("While applying overrides, found level entry='{}' in modpack overrides and worldOutputDirExists={}",
levelEntryName, worldOutputDirExists);

final String overridesDirPrefix = overridesDir + "/";
Expand All @@ -443,12 +445,13 @@ private OverridesResult applyOverrides(Path modpackZip, String overridesDir) thr
ZipEntry entry;
while ((entry = zip.getNextEntry()) != null) {
if (entry.getName().startsWith(overridesDirPrefix)) {
final String subpath = entry.getName().substring(overridesPrefixLen);
final Path outPath = outputDir.resolve(subpath);
if (entry.isDirectory()) {
Files.createDirectories(outPath);
}
else {
if (!entry.isDirectory()) {
if (log.isDebugEnabled()) {
log.debug("Processing override entry={}:{}", entry.isDirectory() ? "D":"F", entry.getName());
}
final String subpath = entry.getName().substring(overridesPrefixLen);
final Path outPath = outputDir.resolve(subpath);

// Rules
// - don't ever overwrite world data
// - user has option to not overwrite any existing file from overrides
Expand All @@ -463,6 +466,8 @@ private OverridesResult applyOverrides(Path modpackZip, String overridesDir) thr

if ( !(overridesSkipExisting && Files.exists(outPath)) ) {
log.debug("Applying override {}", subpath);
// zip files don't always list the directories before the files, so just create-as-needed
Files.createDirectories(outPath.getParent());
Files.copy(zip, outPath, StandardCopyOption.REPLACE_EXISTING);
}
else {
Expand Down