Fix nested directory entries: add full ancestor chain to ZIP
Build & Deploy / build-and-deploy (push) Successful in 45s
Build & Deploy / build-and-deploy (push) Successful in 45s
Previously only the immediate parent directory was added as a ZIP entry. For deeply nested paths like NAS50TH/TRACKS/WILKES/WILKES.DAT, only NAS50TH/TRACKS/WILKES/ was created — but NAS50TH/TRACKS/ and NAS50TH/ were skipped (they're only parents of other directories, never the immediate parent of a file). Emscripten's FS.createDirectory() fails if parent doesn't exist, so intermediate directories must be in the ZIP too. Now walks up the full ancestor chain with a while loop.
This commit is contained in:
@@ -293,15 +293,16 @@ public class UploadResource {
|
||||
Files.walk(extractDir).filter(Files::isRegularFile).forEach(f -> {
|
||||
try {
|
||||
String entryName = extractDir.relativize(f).toString().replace('\\', '/');
|
||||
// Ensure all parent directories have explicit entries
|
||||
// (js-dos Emscripten FS requires explicit directory entries)
|
||||
// Ensure ALL ancestor directories have explicit entries
|
||||
// (Emscripten FS requires every directory in the chain)
|
||||
int idx = entryName.lastIndexOf('/');
|
||||
if (idx >= 0) {
|
||||
while (idx >= 0) {
|
||||
String parent = entryName.substring(0, idx + 1);
|
||||
if (addedDirs.add(parent)) {
|
||||
zos.putNextEntry(new java.util.zip.ZipEntry(parent));
|
||||
zos.closeEntry();
|
||||
}
|
||||
idx = entryName.lastIndexOf('/', idx - 1);
|
||||
}
|
||||
zos.putNextEntry(new java.util.zip.ZipEntry(entryName));
|
||||
Files.copy(f, zos);
|
||||
|
||||
Reference in New Issue
Block a user