Pre Merge pull request !889 from xy/fix/download-code-zip-close

This commit is contained in:
xy 2026-10-09 05:38:52 +00:00 committed by Gitee
commit 05ea5735ed
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -341,8 +341,11 @@ public class GenTableServiceImpl implements IGenTableService {
public byte[] downloadCode(Long tableId) { public byte[] downloadCode(Long tableId) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ZipOutputStream zip = new ZipOutputStream(outputStream); ZipOutputStream zip = new ZipOutputStream(outputStream);
writeCodeToZip(tableId, zip); try {
IoUtil.close(zip); writeCodeToZip(tableId, zip);
} finally {
IoUtil.close(zip);
}
return outputStream.toByteArray(); return outputStream.toByteArray();
} }
@ -408,10 +411,13 @@ public class GenTableServiceImpl implements IGenTableService {
public byte[] downloadCode(String[] tableIds) { public byte[] downloadCode(String[] tableIds) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ZipOutputStream zip = new ZipOutputStream(outputStream); ZipOutputStream zip = new ZipOutputStream(outputStream);
for (String tableId : tableIds) { try {
writeCodeToZip(Long.parseLong(tableId), zip); for (String tableId : tableIds) {
writeCodeToZip(Long.parseLong(tableId), zip);
}
} finally {
IoUtil.close(zip);
} }
IoUtil.close(zip);
return outputStream.toByteArray(); return outputStream.toByteArray();
} }