BlueGit

ict rusty-teams

Merge branch 'fix/ship-pdb' into hotfix-deploy

metis Daniel Däschle · pushed by metis

Authored 2026-10-12 · 7 weeks ago

Hash
6a18d17b7f595c839f9ab3b5acec86e7e98d847a
2 files changed +39 −1
crates/app/src/updater.rs +34 −1
@@ -11,6 +11,7 @@ const VERSION_MARKER: &str = concat!("teams-build:", env!("TEAMS_BUILD_VERSION")
11 11 const UPDATE_DIRECTORY: &str = "update";
12 12 const EXE_NAME: &str = "teams.exe";
13 13 const OLD_EXE_NAME: &str = "teams.old.exe";
14 const PDB_NAME: &str = "teams.pdb";
14 15 const VERSION_FILE_NAME: &str = "version.txt";
15 16 pub const RELAUNCH_ENV: &str = "RUSTY_TEAMS_RELAUNCH";
16 17 const CLEANUP_ATTEMPTS: u32 = 30;
@@ -55,6 +56,8 @@ pub struct UpdatePaths {
55 56 pub old_exe: PathBuf,
56 57 pub update_exe: PathBuf,
57 58 pub version_file: PathBuf,
59 pub pdb: PathBuf,
60 pub update_pdb: PathBuf,
58 61 }
59 62
60 63 impl UpdatePaths {
@@ -66,6 +69,8 @@ impl UpdatePaths {
66 69 old_exe: directory.join(OLD_EXE_NAME),
67 70 update_exe: update_directory.join(EXE_NAME),
68 71 version_file: update_directory.join(VERSION_FILE_NAME),
72 pdb: directory.join(PDB_NAME),
73 update_pdb: update_directory.join(PDB_NAME),
69 74 }
70 75 }
71 76 }
@@ -74,6 +79,7 @@ impl UpdatePaths {
74 79 pub enum FileOperation {
75 80 RemoveIfExists(PathBuf),
76 81 Rename { from: PathBuf, to: PathBuf },
82 ReplaceIfPresent { from: PathBuf, to: PathBuf },
77 83 }
78 84
79 85 pub trait FileSystem {
@@ -109,6 +115,10 @@ pub fn swap_plan(paths: &UpdatePaths) -> Vec<FileOperation> {
109 115 from: paths.update_exe.clone(),
110 116 to: paths.exe.clone(),
111 117 },
118 FileOperation::ReplaceIfPresent {
119 from: paths.update_pdb.clone(),
120 to: paths.pdb.clone(),
121 },
112 122 FileOperation::RemoveIfExists(paths.version_file.clone()),
113 123 ]
114 124 }
@@ -122,6 +132,15 @@ fn apply_operation(files: &dyn FileSystem, operation: &FileOperation) -> io::Res
122 132 Ok(())
123 133 }
124 134 FileOperation::Rename { from, to } => files.rename(from, to),
135 FileOperation::ReplaceIfPresent { from, to } => {
136 if files.exists(from) {
137 if files.exists(to) {
138 let _ = files.remove_file(to);
139 }
140 let _ = files.rename(from, to);
141 }
142 Ok(())
143 }
125 144 }
126 145 }
127 146
@@ -304,7 +323,7 @@ mod tests {
304 323 let paths = UpdatePaths::beside(Path::new("/app/teams.exe"));
305 324 assert_eq!(paths.update_exe, Path::new("/app/update/teams.exe"));
306 325 let plan = swap_plan(&paths);
307 assert_eq!(plan.len(), 4);
326 assert_eq!(plan.len(), 5);
308 327 assert_eq!(
309 328 plan[1],
310 329 FileOperation::Rename {
@@ -341,6 +360,20 @@ mod tests {
341 360 assert!(!paths.version_file.exists());
342 361 }
343 362
363 #[test]
364 fn swap_moves_the_symbols_along_and_works_without_them() {
365 let directory = tempfile::tempdir().unwrap();
366 let paths = install(directory.path());
367 apply_plan(&RealFileSystem, &swap_plan(&paths)).unwrap();
368 assert!(!paths.pdb.exists());
369 let paths = install(directory.path());
370 fs::write(&paths.pdb, "old symbols").unwrap();
371 fs::write(&paths.update_pdb, "new symbols").unwrap();
372 apply_plan(&RealFileSystem, &swap_plan(&paths)).unwrap();
373 assert_eq!(fs::read_to_string(&paths.pdb).unwrap(), "new symbols");
374 assert!(!paths.update_pdb.exists());
375 }
376
344 377 #[test]
345 378 fn swap_replaces_a_leftover_old_exe() {
346 379 let directory = tempfile::tempdir().unwrap();
@@ -11,6 +11,7 @@ const VERSION_MARKER: &str = concat!("teams-build:", env!("TEAMS_BUILD_VERSION")
11const UPDATE_DIRECTORY: &str = "update";
11const UPDATE_DIRECTORY: &str = "update";
12const EXE_NAME: &str = "teams.exe";
12const EXE_NAME: &str = "teams.exe";
13const OLD_EXE_NAME: &str = "teams.old.exe";
13const OLD_EXE_NAME: &str = "teams.old.exe";
14const PDB_NAME: &str = "teams.pdb";
14const VERSION_FILE_NAME: &str = "version.txt";
15const VERSION_FILE_NAME: &str = "version.txt";
15pub const RELAUNCH_ENV: &str = "RUSTY_TEAMS_RELAUNCH";
16pub const RELAUNCH_ENV: &str = "RUSTY_TEAMS_RELAUNCH";
16const CLEANUP_ATTEMPTS: u32 = 30;
17const CLEANUP_ATTEMPTS: u32 = 30;
@@ -55,6 +56,8 @@ pub struct UpdatePaths {
55 pub old_exe: PathBuf,
56 pub old_exe: PathBuf,
56 pub update_exe: PathBuf,
57 pub update_exe: PathBuf,
57 pub version_file: PathBuf,
58 pub version_file: PathBuf,
59 pub pdb: PathBuf,
60 pub update_pdb: PathBuf,
58}
61}
59
62
60impl UpdatePaths {
63impl UpdatePaths {
@@ -66,6 +69,8 @@ impl UpdatePaths {
66 old_exe: directory.join(OLD_EXE_NAME),
69 old_exe: directory.join(OLD_EXE_NAME),
67 update_exe: update_directory.join(EXE_NAME),
70 update_exe: update_directory.join(EXE_NAME),
68 version_file: update_directory.join(VERSION_FILE_NAME),
71 version_file: update_directory.join(VERSION_FILE_NAME),
72 pdb: directory.join(PDB_NAME),
73 update_pdb: update_directory.join(PDB_NAME),
69 }
74 }
70 }
75 }
71}
76}
@@ -74,6 +79,7 @@ impl UpdatePaths {
74pub enum FileOperation {
79pub enum FileOperation {
75 RemoveIfExists(PathBuf),
80 RemoveIfExists(PathBuf),
76 Rename { from: PathBuf, to: PathBuf },
81 Rename { from: PathBuf, to: PathBuf },
82 ReplaceIfPresent { from: PathBuf, to: PathBuf },
77}
83}
78
84
79pub trait FileSystem {
85pub trait FileSystem {
@@ -109,6 +115,10 @@ pub fn swap_plan(paths: &UpdatePaths) -> Vec<FileOperation> {
109 from: paths.update_exe.clone(),
115 from: paths.update_exe.clone(),
110 to: paths.exe.clone(),
116 to: paths.exe.clone(),
111 },
117 },
118 FileOperation::ReplaceIfPresent {
119 from: paths.update_pdb.clone(),
120 to: paths.pdb.clone(),
121 },
112 FileOperation::RemoveIfExists(paths.version_file.clone()),
122 FileOperation::RemoveIfExists(paths.version_file.clone()),
113 ]
123 ]
114}
124}
@@ -122,6 +132,15 @@ fn apply_operation(files: &dyn FileSystem, operation: &FileOperation) -> io::Res
122 Ok(())
132 Ok(())
123 }
133 }
124 FileOperation::Rename { from, to } => files.rename(from, to),
134 FileOperation::Rename { from, to } => files.rename(from, to),
135 FileOperation::ReplaceIfPresent { from, to } => {
136 if files.exists(from) {
137 if files.exists(to) {
138 let _ = files.remove_file(to);
139 }
140 let _ = files.rename(from, to);
141 }
142 Ok(())
143 }
125 }
144 }
126}
145}
127
146
@@ -304,7 +323,7 @@ mod tests {
304 let paths = UpdatePaths::beside(Path::new("/app/teams.exe"));
323 let paths = UpdatePaths::beside(Path::new("/app/teams.exe"));
305 assert_eq!(paths.update_exe, Path::new("/app/update/teams.exe"));
324 assert_eq!(paths.update_exe, Path::new("/app/update/teams.exe"));
306 let plan = swap_plan(&paths);
325 let plan = swap_plan(&paths);
307 assert_eq!(plan.len(), 4);
326 assert_eq!(plan.len(), 5);
308 assert_eq!(
327 assert_eq!(
309 plan[1],
328 plan[1],
310 FileOperation::Rename {
329 FileOperation::Rename {
@@ -341,6 +360,20 @@ mod tests {
341 assert!(!paths.version_file.exists());
360 assert!(!paths.version_file.exists());
342 }
361 }
343
362
363 #[test]
364 fn swap_moves_the_symbols_along_and_works_without_them() {
365 let directory = tempfile::tempdir().unwrap();
366 let paths = install(directory.path());
367 apply_plan(&RealFileSystem, &swap_plan(&paths)).unwrap();
368 assert!(!paths.pdb.exists());
369 let paths = install(directory.path());
370 fs::write(&paths.pdb, "old symbols").unwrap();
371 fs::write(&paths.update_pdb, "new symbols").unwrap();
372 apply_plan(&RealFileSystem, &swap_plan(&paths)).unwrap();
373 assert_eq!(fs::read_to_string(&paths.pdb).unwrap(), "new symbols");
374 assert!(!paths.update_pdb.exists());
375 }
376
344 #[test]
377 #[test]
345 fn swap_replaces_a_leftover_old_exe() {
378 fn swap_replaces_a_leftover_old_exe() {
346 let directory = tempfile::tempdir().unwrap();
379 let directory = tempfile::tempdir().unwrap();
scripts/deploy-windows.sh +5 −0
@@ -17,6 +17,11 @@ updateDirectory="$installRoot/update"
17 17 mkdir -p "$updateDirectory"
18 18 cp "$sourceExe" "$updateDirectory/teams.exe.partial"
19 19 mv -f "$updateDirectory/teams.exe.partial" "$updateDirectory/teams.exe"
20 sourcePdb="${sourceExe%.exe}.pdb"
21 if [ -f "$sourcePdb" ]; then
22 cp "$sourcePdb" "$updateDirectory/teams.pdb.partial"
23 mv -f "$updateDirectory/teams.pdb.partial" "$updateDirectory/teams.pdb"
24 fi
20 25 printf '%s\n' "$version" > "$updateDirectory/version.txt.partial"
21 26 mv -f "$updateDirectory/version.txt.partial" "$updateDirectory/version.txt"
22 27 echo "deployed $version to $updateDirectory"
@@ -17,6 +17,11 @@ updateDirectory="$installRoot/update"
17mkdir -p "$updateDirectory"
17mkdir -p "$updateDirectory"
18cp "$sourceExe" "$updateDirectory/teams.exe.partial"
18cp "$sourceExe" "$updateDirectory/teams.exe.partial"
19mv -f "$updateDirectory/teams.exe.partial" "$updateDirectory/teams.exe"
19mv -f "$updateDirectory/teams.exe.partial" "$updateDirectory/teams.exe"
20sourcePdb="${sourceExe%.exe}.pdb"
21if [ -f "$sourcePdb" ]; then
22 cp "$sourcePdb" "$updateDirectory/teams.pdb.partial"
23 mv -f "$updateDirectory/teams.pdb.partial" "$updateDirectory/teams.pdb"
24fi
20printf '%s\n' "$version" > "$updateDirectory/version.txt.partial"
25printf '%s\n' "$version" > "$updateDirectory/version.txt.partial"
21mv -f "$updateDirectory/version.txt.partial" "$updateDirectory/version.txt"
26mv -f "$updateDirectory/version.txt.partial" "$updateDirectory/version.txt"
22echo "deployed $version to $updateDirectory"
27echo "deployed $version to $updateDirectory"