src/bin/proxmox-backup-client.rs: login before starting backup

This commit is contained in:
Dietmar Maurer 2019-03-01 06:48:41 +01:00
parent 1757747836
commit 51144821f9
2 changed files with 10 additions and 6 deletions

View File

@ -175,13 +175,10 @@ fn create_backup(
};
if (stat.st_mode & libc::S_IFDIR) != 0 {
let stream = CaTarBackupStream::open(filename)?;
let body = Body::wrap_stream(stream);
let target = format!("{}.catar", target);
upload_list.push((body, filename.to_owned(), target));
upload_list.push((filename.to_owned(), target));
} else if (stat.st_mode & (libc::S_IFREG|libc::S_IFBLK)) != 0 {
if stat.st_size <= 0 { bail!("got strange file size '{}'", stat.st_size); }
@ -204,8 +201,15 @@ fn create_backup(
let mut client = HttpClient::new(&repo.host, &repo.user);
for (body, filename, target) in upload_list {
client.login()?; // login before starting backup
for (filename, target) in upload_list {
println!("Upload '{}' to '{:?}'", filename, repo);
let stream = CaTarBackupStream::open(&filename)?;
let body = Body::wrap_stream(stream);
backup_directory(&mut client, &repo, body, &target, backup_time, chunk_size_opt)?;
}

View File

@ -163,7 +163,7 @@ impl HttpClient {
Self::run_request(request)
}
fn login(&mut self) -> Result<(String, String), Error> {
pub fn login(&mut self) -> Result<(String, String), Error> {
if let Some(ref ticket) = self.ticket {
if let Some(ref token) = self.token {