src/api2/admin/datastore/backup.rs: ignore error after finish, register known_chunks
This commit is contained in:
parent
40f4e198a8
commit
a95849321c
@ -119,10 +119,15 @@ fn upgrade_to_backup_protocol(
|
|||||||
})
|
})
|
||||||
.then(move |result| {
|
.then(move |result| {
|
||||||
if let Err(err) = result {
|
if let Err(err) = result {
|
||||||
env2.log(format!("backup failed: {}", err));
|
match env2.ensure_finished() {
|
||||||
env2.log("removing failed backup");
|
Ok(()) => {}, // ignorte error after finish
|
||||||
env2.remove_backup()?;
|
_ => {
|
||||||
return Err(err);
|
env2.log(format!("backup failed: {}", err));
|
||||||
|
env2.log("removing failed backup");
|
||||||
|
env2.remove_backup()?;
|
||||||
|
return Err(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
@ -337,6 +342,8 @@ fn dynamic_chunk_index(
|
|||||||
|
|
||||||
let env: &BackupEnvironment = rpcenv.as_ref();
|
let env: &BackupEnvironment = rpcenv.as_ref();
|
||||||
|
|
||||||
|
println!("TEST CHUNK DOWNLOAD");
|
||||||
|
|
||||||
let mut archive_name = tools::required_string_param(¶m, "archive-name")?.to_owned();
|
let mut archive_name = tools::required_string_param(¶m, "archive-name")?.to_owned();
|
||||||
|
|
||||||
if !archive_name.ends_with(".pxar") {
|
if !archive_name.ends_with(".pxar") {
|
||||||
@ -345,21 +352,34 @@ fn dynamic_chunk_index(
|
|||||||
archive_name.push_str(".didx");
|
archive_name.push_str(".didx");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let empty_response = {
|
||||||
|
Response::builder()
|
||||||
|
.status(StatusCode::OK)
|
||||||
|
.body(Body::empty())?
|
||||||
|
};
|
||||||
|
|
||||||
let last_backup = match &env.last_backup {
|
let last_backup = match &env.last_backup {
|
||||||
Some(info) => info,
|
Some(info) => info,
|
||||||
None => {
|
None => return Ok(Box::new(future::ok(empty_response))),
|
||||||
let response = Response::builder()
|
|
||||||
.status(StatusCode::OK)
|
|
||||||
.body(Body::empty())?;
|
|
||||||
return Ok(Box::new(future::ok(response)));
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut path = last_backup.backup_dir.relative_path();
|
let mut path = last_backup.backup_dir.relative_path();
|
||||||
path.push(archive_name);
|
path.push(&archive_name);
|
||||||
|
|
||||||
let index = env.datastore.open_dynamic_reader(path)?;
|
let index = match env.datastore.open_dynamic_reader(path) {
|
||||||
// fixme: register index so that client can refer to it by ID
|
Ok(index) => index,
|
||||||
|
Err(_) => {
|
||||||
|
env.log(format!("there is no last backup for archive '{}'", archive_name));
|
||||||
|
return Ok(Box::new(future::ok(empty_response)));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let count = index.index_count();
|
||||||
|
for pos in 0..count {
|
||||||
|
let (start, end, digest) = index.chunk_info(pos)?;
|
||||||
|
let size = (end - start) as u32;
|
||||||
|
env.register_chunk(digest, size)?;
|
||||||
|
}
|
||||||
|
|
||||||
let reader = ChunkListReader::new(Box::new(index));
|
let reader = ChunkListReader::new(Box::new(index));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user