MCPcopy Create free account
hub / github.com/BitVM/BitVM / list_objects

Method list_objects

bridge/src/client/data_store/sftp.rs:168–193  ·  view source on GitHub ↗
(&self, file_path: Option<&str>)

Source from the content-addressed store, hash-verified

166#[async_trait]
167impl DataStoreDriver for Sftp {
168 async fn list_objects(&self, file_path: Option<&str>) -> Result<Vec<String>, String> {
169 match connect(&self.credentials).await {
170 Ok(sftp) => {
171 let mut fs = sftp.fs();
172 match fs.open_dir(file_path.unwrap_or(".")).await {
173 Ok(dir) => {
174 let mut read_dir = Box::pin(dir.read_dir());
175 let mut buffer: Vec<String> = vec![];
176 while let Some(entry) = read_dir.try_next().await.unwrap() {
177 buffer.push(entry.filename().to_str().unwrap().to_string());
178 }
179 drop(read_dir);
180 drop(fs);
181 disconnect(sftp).await;
182 Ok(buffer)
183 }
184 Err(err) => {
185 drop(fs);
186 disconnect(sftp).await;
187 Err(format!("Unable to list objects: {}", err))
188 }
189 }
190 }
191 Err(err) => Err(format!("Unable tolist objects: {}", err)),
192 }
193 }
194
195 async fn fetch_object(
196 &self,

Callers 4

get_file_namesMethod · 0.45
test_sftpFunction · 0.45
test_ftpFunction · 0.45
test_ftpsFunction · 0.45

Calls 3

connectFunction · 0.85
disconnectFunction · 0.70
pushMethod · 0.45

Tested by 3

test_sftpFunction · 0.36
test_ftpFunction · 0.36
test_ftpsFunction · 0.36