Skip to content

Commit 538f6c7

Browse files
committed
Fix #7
1 parent 00141d0 commit 538f6c7

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

src/agent/factorio.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,20 @@ mod tests {
145145

146146
Ok(())
147147
}
148+
149+
#[tokio::test]
150+
async fn can_install_version_2_0_28() -> std::result::Result<(), Box<dyn std::error::Error>> {
151+
fctrl::util::testing::logger_init();
152+
153+
let tmp_dir = std::env::temp_dir().join(Uuid::new_v4().to_string());
154+
fs::create_dir(&tmp_dir).await?;
155+
let mut vm = VersionManager::new(&tmp_dir).await?;
156+
vm.install("2.0.28".to_owned()).await?;
157+
158+
assert!(vm.versions.contains_key("2.0.28"));
159+
160+
let _ = fs::remove_dir_all(tmp_dir).await;
161+
162+
Ok(())
163+
}
148164
}

src/agent/main.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,6 +1030,28 @@ impl AgentController {
10301030
map_settings: Option<MapSettingsJson>,
10311031
operation_id: OperationId,
10321032
) {
1033+
// Fail if save with same name already exists
1034+
match util::saves::exists_savefile(&save_name).await {
1035+
Ok(false) => {
1036+
// ok
1037+
},
1038+
Ok(true) => {
1039+
self.reply_failed(
1040+
AgentOutMessage::Error(format!("Savefile with name {} already exists", save_name)),
1041+
operation_id)
1042+
.await;
1043+
return
1044+
},
1045+
Err(e) => {
1046+
error!("Failed to check if savefile with name {} already exists: {:?}", save_name, e);
1047+
self.reply_failed(
1048+
AgentOutMessage::Error(format!("Failed to check if savefile with name {} already exists: {:?}", save_name, e)),
1049+
operation_id)
1050+
.await;
1051+
return;
1052+
},
1053+
}
1054+
10331055
// assume there is at most one version installed
10341056
if let Ok(version_mg) =
10351057
tokio::time::timeout(Duration::from_millis(250), self.version_manager.read()).await

0 commit comments

Comments
 (0)