file size limits, keep active filters in session

This commit is contained in:
Stefan Hardegger
2025-10-30 13:11:40 +01:00
parent 924ae12b5b
commit a3bc83db8a
7 changed files with 112 additions and 25 deletions

View File

@@ -354,14 +354,24 @@ public class DatabaseManagementService implements ApplicationContextAware {
Path tempBackupFile = Files.createTempFile("storycove_restore_", ".sql");
try {
// Write backup stream to temporary file
// Write backup stream to temporary file, filtering out incompatible commands
System.err.println("Writing backup data to temporary file...");
try (InputStream input = backupStream;
OutputStream output = Files.newOutputStream(tempBackupFile)) {
byte[] buffer = new byte[8192];
int bytesRead;
while ((bytesRead = input.read(buffer)) != -1) {
output.write(buffer, 0, bytesRead);
BufferedReader reader = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8));
BufferedWriter writer = Files.newBufferedWriter(tempBackupFile, StandardCharsets.UTF_8)) {
String line;
while ((line = reader.readLine()) != null) {
// Skip DROP DATABASE and CREATE DATABASE commands - we're already connected to the DB
// Also skip database connection commands as we're already connected
if (line.trim().startsWith("DROP DATABASE") ||
line.trim().startsWith("CREATE DATABASE") ||
line.trim().startsWith("\\connect")) {
System.err.println("Skipping incompatible command: " + line.substring(0, Math.min(50, line.length())));
continue;
}
writer.write(line);
writer.newLine();
}
}

View File

@@ -21,8 +21,8 @@ spring:
servlet:
multipart:
max-file-size: 600MB # Increased for large backup restore (425MB+)
max-request-size: 610MB # Slightly higher to account for form data
max-file-size: 2048MB # 2GB for large backup restore
max-request-size: 2100MB # Slightly higher to account for form data
jackson:
serialization:
@@ -33,7 +33,7 @@ spring:
server:
port: 8080
tomcat:
max-http-request-size: 650MB # Tomcat HTTP request size limit (separate from multipart)
max-http-request-size: 2150MB # Tomcat HTTP request size limit (2GB + overhead)
storycove:
app: