Simplify pack building and remove obsolete address fallback
This commit is contained in:
@@ -16,6 +16,7 @@ import java.security.DigestInputStream;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HexFormat;
|
||||
import java.util.Locale;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
@@ -75,12 +76,8 @@ public final class PackBuilder {
|
||||
throws IOException {
|
||||
// Shared with server-side exporters (AstraPlus). A build must see one complete asset
|
||||
// generation.
|
||||
String lock =
|
||||
"AstraPacks:contents:"
|
||||
+ contents.toAbsolutePath()
|
||||
.normalize()
|
||||
.toString()
|
||||
.toLowerCase(java.util.Locale.ROOT);
|
||||
Path directory = contents.toAbsolutePath().normalize();
|
||||
String lock = "AstraPacks:contents:" + directory.toString().toLowerCase(Locale.ROOT);
|
||||
synchronized (lock.intern()) {
|
||||
return writeLockedArchive(contents, target, resourceVersion);
|
||||
}
|
||||
@@ -90,6 +87,8 @@ public final class PackBuilder {
|
||||
throws IOException {
|
||||
int files = 0;
|
||||
long totalBytes = 0;
|
||||
long maxFileBytes = config.build.maxFileMiB * 1024L * 1024L;
|
||||
long maxTotalBytes = config.build.maxTotalMiB * 1024L * 1024L;
|
||||
try (var paths = Files.walk(contents);
|
||||
var zip =
|
||||
new ZipOutputStream(
|
||||
@@ -115,10 +114,8 @@ public final class PackBuilder {
|
||||
ZipEntry entry = new ZipEntry(name);
|
||||
entry.setTime(0);
|
||||
zip.putNextEntry(entry);
|
||||
long limit =
|
||||
Math.min(
|
||||
config.build.maxFileMiB * 1024L * 1024L,
|
||||
config.build.maxTotalMiB * 1024L * 1024L - totalBytes);
|
||||
long availableBytes = maxTotalBytes - totalBytes;
|
||||
long limit = Math.min(maxFileBytes, availableBytes);
|
||||
totalBytes += copyResource(file, zip, limit);
|
||||
zip.closeEntry();
|
||||
}
|
||||
|
||||
@@ -91,10 +91,6 @@ public final class PackConfig {
|
||||
if (config == null) {
|
||||
throw new IllegalArgumentException("Empty config");
|
||||
}
|
||||
// Old automatic addressing is no longer supported; leave it for the owner to set.
|
||||
if (config.hosting != null && "auto".equals(config.hosting.publicAddress)) {
|
||||
config.hosting.publicAddress = "";
|
||||
}
|
||||
config.validate();
|
||||
return config;
|
||||
} catch (RuntimeException e) {
|
||||
|
||||
Reference in New Issue
Block a user