Resilient flatten: catch exceptions + return meaningful error messages
Build & Deploy / build-and-deploy (push) Successful in 47s
Build & Deploy / build-and-deploy (push) Successful in 47s
- Wrap flattenSingleDir in try-catch — if it fails, the upload continues and the cd <subdir> fix in dosbox.conf handles subdirectory executables - Add global catch to upload method returning the actual exception message instead of a generic 500 - This will help diagnose why the user's King's Quest VI zip fails: flattening can throw on special filenames, Mac resource forks, symlinks, or other unusual ZIP contents
This commit is contained in:
@@ -64,7 +64,12 @@ public class UploadResource {
|
|||||||
Path extractDir = tmpDir.resolve("extracted");
|
Path extractDir = tmpDir.resolve("extracted");
|
||||||
unzip(zipPath, extractDir);
|
unzip(zipPath, extractDir);
|
||||||
// If the ZIP has a single root directory, flatten it
|
// If the ZIP has a single root directory, flatten it
|
||||||
|
try {
|
||||||
flattenSingleDir(extractDir);
|
flattenSingleDir(extractDir);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.warning("Flatten failed for '" + filename + "': " + e.getMessage()
|
||||||
|
+ " — continuing (cd in autoexec handles subdirs)");
|
||||||
|
}
|
||||||
|
|
||||||
// Find main executable
|
// Find main executable
|
||||||
String mainExe = findMainExe(extractDir);
|
String mainExe = findMainExe(extractDir);
|
||||||
@@ -120,6 +125,11 @@ public class UploadResource {
|
|||||||
|
|
||||||
return Response.status(201).entity(game).build();
|
return Response.status(201).entity(game).build();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.severe("Upload failed for '" + filename + "': " + e.getMessage());
|
||||||
|
return Response.serverError()
|
||||||
|
.entity(Map.of("error", "Upload failed: " + e.getMessage()))
|
||||||
|
.build();
|
||||||
} finally {
|
} finally {
|
||||||
deleteDir(tmpDir);
|
deleteDir(tmpDir);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user