aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--planetwars-server/src/db/bots.rs11
-rw-r--r--planetwars-server/src/modules/bots.rs7
-rw-r--r--planetwars-server/src/routes/bots.rs7
3 files changed, 14 insertions, 11 deletions
diff --git a/planetwars-server/src/db/bots.rs b/planetwars-server/src/db/bots.rs
index 53c11b1..1654f43 100644
--- a/planetwars-server/src/db/bots.rs
+++ b/planetwars-server/src/db/bots.rs
@@ -45,9 +45,10 @@ pub fn find_all_bots(conn: &PgConnection) -> QueryResult<Vec<Bot>> {
#[derive(Insertable)]
#[table_name = "bot_versions"]
-pub struct NewCodeBundle<'a> {
+pub struct NewBotVersion<'a> {
pub bot_id: Option<i32>,
- pub code_bundle_path: &'a str,
+ pub code_bundle_path: Option<&'a str>,
+ pub container_digest: Option<&'a str>,
}
#[derive(Queryable, Serialize, Deserialize, Debug)]
@@ -59,12 +60,12 @@ pub struct BotVersion {
pub container_digest: Option<String>,
}
-pub fn create_code_bundle(
- new_code_bundle: &NewCodeBundle,
+pub fn create_bot_version(
+ new_bot_version: &NewBotVersion,
conn: &PgConnection,
) -> QueryResult<BotVersion> {
diesel::insert_into(bot_versions::table)
- .values(new_code_bundle)
+ .values(new_bot_version)
.get_result(conn)
}
diff --git a/planetwars-server/src/modules/bots.rs b/planetwars-server/src/modules/bots.rs
index cd26ee0..629ecf6 100644
--- a/planetwars-server/src/modules/bots.rs
+++ b/planetwars-server/src/modules/bots.rs
@@ -15,9 +15,10 @@ pub fn save_code_bundle(
std::fs::create_dir(&code_bundle_dir).unwrap();
std::fs::write(code_bundle_dir.join("bot.py"), bot_code).unwrap();
- let new_code_bundle = db::bots::NewCodeBundle {
+ let new_code_bundle = db::bots::NewBotVersion {
bot_id,
- code_bundle_path: &bundle_name,
+ code_bundle_path: Some(&bundle_name),
+ container_digest: None,
};
- db::bots::create_code_bundle(&new_code_bundle, conn)
+ db::bots::create_bot_version(&new_code_bundle, conn)
}
diff --git a/planetwars-server/src/routes/bots.rs b/planetwars-server/src/routes/bots.rs
index 1ffedef..54c0d36 100644
--- a/planetwars-server/src/routes/bots.rs
+++ b/planetwars-server/src/routes/bots.rs
@@ -213,12 +213,13 @@ pub async fn upload_code_multipart(
.extract(bots_dir.join(&folder_name))
.map_err(|_| StatusCode::BAD_REQUEST)?;
- let bundle = bots::NewCodeBundle {
+ let bot_version = bots::NewBotVersion {
bot_id: Some(bot.id),
- code_bundle_path: &folder_name,
+ code_bundle_path: Some(&folder_name),
+ container_digest: None,
};
let code_bundle =
- bots::create_code_bundle(&bundle, &conn).expect("Failed to create code bundle");
+ bots::create_bot_version(&bot_version, &conn).expect("Failed to create code bundle");
Ok(Json(code_bundle))
}