@@ -4,7 +4,6 @@ use std::{
44 sync:: Arc ,
55} ;
66
7- use directories:: ProjectDirs ;
87use etcetera:: BaseStrategy ;
98use fs_err as fs;
109use tempfile:: { tempdir, TempDir } ;
@@ -85,10 +84,7 @@ impl StateStore {
8584 pub fn from_settings ( state_dir : Option < PathBuf > ) -> Result < Self , io:: Error > {
8685 if let Some ( state_dir) = state_dir {
8786 StateStore :: from_path ( state_dir)
88- } else if let Some ( data_dir) = ProjectDirs :: from ( "" , "" , "uv" )
89- . map ( |dirs| dirs. data_dir ( ) . to_path_buf ( ) )
90- . filter ( |dir| dir. exists ( ) )
91- {
87+ } else if let Some ( data_dir) = legacy_data_dir ( ) . filter ( |dir| dir. exists ( ) ) {
9288 // If the user has an existing directory at (e.g.) `/Users/user/Library/Application Support/uv`,
9389 // respect it for backwards compatibility. Otherwise, prefer the XDG strategy, even on
9490 // macOS.
@@ -104,6 +100,13 @@ impl StateStore {
104100 }
105101}
106102
103+ fn legacy_data_dir ( ) -> Option < PathBuf > {
104+ etcetera:: base_strategy:: choose_native_strategy ( )
105+ . ok ( )
106+ . map ( |dirs| dirs. data_dir ( ) . join ( "uv" ) )
107+ . map ( |dir| if cfg ! ( windows) { dir. join ( "data" ) } else { dir } )
108+ }
109+
107110/// The different kinds of data in the state store are stored in different bucket, which in our case
108111/// are subdirectories of the state store root.
109112#[ derive( Debug , Clone , Copy , Eq , PartialEq , Hash ) ]
0 commit comments