|
67 | 67 | import java.nio.charset.Charset; |
68 | 68 | import java.nio.charset.StandardCharsets; |
69 | 69 | import java.nio.file.Files; |
| 70 | +import java.nio.file.Path; |
70 | 71 | import java.nio.file.Paths; |
71 | 72 | import java.sql.Connection; |
72 | 73 | import java.sql.PreparedStatement; |
@@ -118,7 +119,7 @@ public class ExportStarterUtil { |
118 | 119 | private static final Lazy<Integer> QUEUE_CAPACITY = |
119 | 120 | Lazy.of(() -> Config.getIntProperty(STARTER_GENERATION_QUEUE_CAPACITY_PROP, 1000)); |
120 | 121 | private static final Lazy<String> ZIP_FILE_ASSETS_FOLDER = |
121 | | - Lazy.of(() -> Config.getStringProperty(STARTER_GENERATION_ASSETS_FOLDER_PROP, "/assets/")); |
| 122 | + Lazy.of(() -> Config.getStringProperty(STARTER_GENERATION_ASSETS_FOLDER_PROP, "assets")); |
122 | 123 |
|
123 | 124 | private static final String JSON_FILE_EXT = ".json"; |
124 | 125 |
|
@@ -484,10 +485,28 @@ private void addFolderToZip(final ZipOutputStream zip, final FileFilter fileFilt |
484 | 485 | return; |
485 | 486 | } |
486 | 487 | FileUtil.listFilesRecursively(source, fileFilter).stream().filter(File::isFile).forEach(file -> { |
487 | | - final String filePath = file.getPath().replace(ConfigUtils.getAssetPath(), ZIP_FILE_ASSETS_FOLDER.get()); |
488 | | - Logger.debug(this, String.format("-> File path: %s", filePath)); |
489 | | - final FileEntry entry = new FileEntry(filePath, file); |
490 | | - this.addFileToZip(entry, zip); |
| 488 | + try { |
| 489 | + Path sourcePath = Paths.get(ConfigUtils.getAssetPath()).normalize(); |
| 490 | + Path currentFilePath = file.toPath().normalize(); |
| 491 | + Path targetFolderPath = Paths.get(ZIP_FILE_ASSETS_FOLDER.get()).normalize(); |
| 492 | + |
| 493 | + // Get relative path from source to current file |
| 494 | + Path relativePath = sourcePath.relativize(currentFilePath); |
| 495 | + |
| 496 | + // Construct the final path by combining target folder with relative path |
| 497 | + Path finalPath = targetFolderPath.resolve(relativePath); |
| 498 | + |
| 499 | + // Convert to string with forward slashes for ZIP compatibility |
| 500 | + String filePath = finalPath.toString().replace('\\', '/'); |
| 501 | + |
| 502 | + Logger.debug(this, String.format("-> File path: %s", filePath)); |
| 503 | + final FileEntry entry = new FileEntry(filePath, file); |
| 504 | + this.addFileToZip(entry, zip); |
| 505 | + |
| 506 | + } catch (Exception e) { |
| 507 | + Logger.error(this, String.format("Error processing file path for %s: %s", |
| 508 | + file.getPath(), e.getMessage())); |
| 509 | + } |
491 | 510 | }); |
492 | 511 |
|
493 | 512 |
|
|
0 commit comments