@@ -8,6 +8,7 @@ use tokio::io;
88
99pub mod error;
1010use error:: * ;
11+ mod registration;
1112mod upgrade;
1213
1314pub use asimov_module:: layout:: MANIFEST_FILE_NAME ;
@@ -86,47 +87,6 @@ impl Registry {
8687 self . install_dir . join ( module_name. as_str ( ) )
8788 }
8889
89- pub async fn add_module (
90- & self ,
91- module_name : & ModuleName ,
92- dir : impl AsRef < Path > ,
93- ) -> Result < ( ) , AddModuleError > {
94- if self . is_module_installed ( module_name) . await . unwrap_or ( false ) {
95- return Err ( AddModuleError :: AlreadyInstalled ) ;
96- }
97-
98- let module_dir = self . module_dir ( module_name) ;
99-
100- tokio:: fs:: rename ( dir. as_ref ( ) , & module_dir)
101- . await
102- . map_err ( |e| AddModuleError :: Install ( dir. as_ref ( ) . into ( ) , module_dir. clone ( ) , e) ) ?;
103-
104- let bin_dir = module_dir. join ( BIN_DIR_NAME ) ;
105-
106- let mut entries = match tokio:: fs:: read_dir ( & bin_dir) . await {
107- Ok ( entries) => entries,
108- Err ( err) if err. kind ( ) == io:: ErrorKind :: NotFound => return Ok ( ( ) ) ,
109- Err ( err) => return Err ( AddModuleError :: ReadBinDir ( bin_dir, err) ) ,
110- } ;
111-
112- while let Some ( entry) = entries
113- . next_entry ( )
114- . await
115- . map_err ( |e| AddModuleError :: ReadBinDir ( bin_dir. clone ( ) , e) ) ?
116- {
117- let program_name = entry. file_name ( ) ;
118- let Some ( program_name) = program_name. to_str ( ) else {
119- continue ;
120- } ;
121-
122- self . add_binary ( program_name, & entry. path ( ) )
123- . await
124- . map_err ( |e| AddModuleError :: AddBinary ( program_name. into ( ) , e) ) ?;
125- }
126-
127- Ok ( ( ) )
128- }
129-
13090 pub async fn read_manifest (
13191 & self ,
13292 module_name : & ModuleName ,
@@ -167,6 +127,9 @@ impl Registry {
167127 . map_err ( Into :: into)
168128 }
169129
130+ /// Remove only the module directory. Prefer [`Self::uninstall_module`] to
131+ /// transactionally remove the directory and its owned links together.
132+ /// This low-level operation must not overlap a publication transaction.
170133 pub async fn remove_module ( & self , module_name : & ModuleName ) -> Result < ( ) , RemoveModuleError > {
171134 self . migrate_legacy_manifest ( module_name) . await ;
172135
@@ -181,22 +144,9 @@ impl Registry {
181144 . map_err ( |e| RemoveModuleError :: RemoveModuleDir ( module_dir, e) )
182145 }
183146
184- async fn add_binary ( & self , program_name : & str , binary_path : & Path ) -> io:: Result < ( ) > {
185- let target_path = match self
186- . exec_dir
187- . parent ( )
188- . and_then ( |parent| binary_path. strip_prefix ( parent) . ok ( ) )
189- {
190- Some ( suffix) => PathBuf :: from ( ".." ) . join ( suffix) ,
191- None => binary_path. into ( ) ,
192- } ;
193-
194- let link_path = self . exec_dir . join ( program_name) ;
195- let _ = self . remove_binary ( program_name) . await ;
196-
197- create_symlink ( & target_path, & link_path, false ) . await
198- }
199-
147+ /// Unconditionally remove an executable entry, without checking ownership.
148+ /// Prefer [`Self::uninstall_module`] when removing a module. This low-level
149+ /// operation must not overlap a publication transaction.
200150 pub async fn remove_binary ( & self , name : impl AsRef < str > ) -> Result < ( ) , RemoveBinaryError > {
201151 let name = name. as_ref ( ) ;
202152
0 commit comments