D2: remote browser operations, compare and sync in lutra-deploy
Remote trait gains remove_file, remove_dir and rename (SFTP, FTP, folder; test servers too). browse: list, read as text (binary and size caps), write, rename, mkdir, recursive delete that never takes the root. job: compare (local only, server only, different by size then contents) and sync (uploads plus explicitly listed deletions). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
064f40839f
commit
a8ad74755c
10 changed files with 854 additions and 29 deletions
|
|
@ -115,6 +115,25 @@ pub trait Remote {
|
|||
/// [`DeployError::Transfer`] when the server refuses.
|
||||
fn list(&mut self, path: &str) -> Result<Vec<Entry>>;
|
||||
|
||||
/// Removes the file `path`.
|
||||
///
|
||||
/// # Errors
|
||||
/// [`DeployError::Transfer`] when the server refuses.
|
||||
fn remove_file(&mut self, path: &str) -> Result<()>;
|
||||
|
||||
/// Removes the empty folder `path`.
|
||||
///
|
||||
/// # Errors
|
||||
/// [`DeployError::Transfer`] when the server refuses (also when the
|
||||
/// folder is not empty).
|
||||
fn remove_dir(&mut self, path: &str) -> Result<()>;
|
||||
|
||||
/// Renames or moves `from` to `to` on the server.
|
||||
///
|
||||
/// # Errors
|
||||
/// [`DeployError::Transfer`] when the server refuses.
|
||||
fn rename(&mut self, from: &str, to: &str) -> Result<()>;
|
||||
|
||||
/// Ends the session politely; failures are ignored because the
|
||||
/// connection is dropped anyway.
|
||||
fn close(&mut self);
|
||||
|
|
@ -247,6 +266,27 @@ impl Remote for Folder {
|
|||
Ok(entries)
|
||||
}
|
||||
|
||||
fn remove_file(&mut self, path: &str) -> Result<()> {
|
||||
let path = self.resolve(path)?;
|
||||
std::fs::remove_file(&path).map_err(|e| io_error(&path, &e))
|
||||
}
|
||||
|
||||
fn remove_dir(&mut self, path: &str) -> Result<()> {
|
||||
let path = self.resolve(path)?;
|
||||
if path == self.root {
|
||||
return Err(DeployError::Invalid(
|
||||
"the deployment folder itself cannot be removed".into(),
|
||||
));
|
||||
}
|
||||
std::fs::remove_dir(&path).map_err(|e| io_error(&path, &e))
|
||||
}
|
||||
|
||||
fn rename(&mut self, from: &str, to: &str) -> Result<()> {
|
||||
let from = self.resolve(from)?;
|
||||
let to = self.resolve(to)?;
|
||||
std::fs::rename(&from, &to).map_err(|e| io_error(&from, &e))
|
||||
}
|
||||
|
||||
fn close(&mut self) {}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue