11use spacetimedb_paths:: SpacetimePaths ;
2+ use std:: path:: Path ;
23
34/// List installed SpacetimeDB versions.
45#[ derive( clap:: Args ) ]
@@ -10,7 +11,31 @@ pub(super) struct List {
1011
1112impl List {
1213 pub ( super ) fn exec ( self , paths : & SpacetimePaths ) -> anyhow:: Result < ( ) > {
13- let current = paths. cli_bin_dir . current_version ( ) ?;
14+ // This `match` part is only here because at one point we had a bug where we were creating
15+ // symlinks that contained the _entire_ path, rather than just the relative path to the
16+ // version directory. It's not strictly necessary, it just fixes our determination of what
17+ // the current version is, for the output of this command.
18+ //
19+ // That symlink bug was fixed in `crates/paths/src/cli.rs` in
20+ // https://github.com/clockworklabs/SpacetimeDB/pull/2680, but this `match` means that this
21+ // output will still be correct for any users that already have one of the bugged symlinks.
22+ //
23+ // Once users upgrade to a version containing #2680, they will have the code that creates
24+ // the fixed symlinks. However, that code won't immediately run, since the upgrade will be
25+ // running from the previous binary they had. So once they upgrade to a version containing
26+ // #2680, _and then_ upgrade once more, their symlinks will be fixed. There's no real
27+ // timeline on when everyone will have done that, but hopefully that helps give a sense of
28+ // how long this code "should" exist for (but it doesn't do any harm afaik).
29+ let current = match paths. cli_bin_dir . current_version ( ) ? {
30+ None => None ,
31+ Some ( path_str) => {
32+ let file_name = Path :: new ( & path_str)
33+ . file_name ( )
34+ . and_then ( |f| f. to_str ( ) )
35+ . ok_or ( anyhow:: anyhow!( "Could not extract current version" ) ) ?;
36+ Some ( file_name. to_string ( ) )
37+ }
38+ } ;
1439 let versions = if self . all {
1540 let client = super :: reqwest_client ( ) ?;
1641 super :: tokio_block_on ( super :: install:: available_releases ( & client) ) ??
0 commit comments