From 9ad52d0151086252e6d8a3e60dc5b8cd4bfd5465 Mon Sep 17 00:00:00 2001 From: salmonik Date: Sun, 12 Jul 2026 21:35:25 +0200 Subject: second stable --- src/routes/backups.rs | 58 --------------------------------------------------- 1 file changed, 58 deletions(-) (limited to 'src/routes/backups.rs') diff --git a/src/routes/backups.rs b/src/routes/backups.rs index 09298d2..6b4dd49 100644 --- a/src/routes/backups.rs +++ b/src/routes/backups.rs @@ -37,7 +37,6 @@ pub fn router() -> Router { .route("/instances/{id}/backups/create", post(create_backup)) .route("/backups/{id}/restore", post(restore_backup)) .route("/backups/{id}/download", get(download_backup)) - .route("/instances/{id}/world/export", get(export_world)) } async fn list_backups( @@ -197,60 +196,3 @@ async fn download_backup( .body(Body::from(content)) .unwrap()) } - -async fn export_world( - State(state): State, - Path(instance_id): Path, - CurrentUser(_user): CurrentUser, -) -> Result { - let conn = state.db.conn(); - let instance_name: String = conn - .query_row( - "SELECT name FROM instances WHERE id = ?1", - params![instance_id], - |row| row.get(0), - ) - .map_err(|_| (StatusCode::NOT_FOUND, "Instance not found"))?; - drop(conn); - - let world_dir = state - .config - .server_directory - .join("instances") - .join(&instance_name) - .join("data") - .join("world"); - - let mut zip_buf = Vec::new(); - { - let mut zip = zip::ZipWriter::new(std::io::Cursor::new(&mut zip_buf)); - let options: FileOptions<'_, ()> = - FileOptions::default().compression_method(zip::CompressionMethod::Deflated); - - if let Ok(entries) = std::fs::read_dir(&world_dir) { - for entry in entries.flatten() { - let path = entry.path(); - if path.is_file() { - if let Some(name) = path.file_name() { - if let Ok(contents) = std::fs::read(&path) { - let _ = zip.start_file(&*name.to_string_lossy(), options); - let _ = std::io::Write::write_all(&mut zip, &contents); - } - } - } - } - } - let _ = zip.finish(); - } - - let filename = format!("{instance_name}_world.zip"); - - Ok(Response::builder() - .header(header::CONTENT_TYPE, "application/zip") - .header( - header::CONTENT_DISPOSITION, - format!("attachment; filename=\"{filename}\""), - ) - .body(Body::from(zip_buf)) - .unwrap()) -} -- cgit v1.2.3