forked from Deuxfleurs/garage
fix online repair
This commit is contained in:
parent
bb176ebcb8
commit
75a0e01372
1 changed files with 18 additions and 17 deletions
|
@ -107,28 +107,29 @@ impl Worker for RepairVersionsWorker {
|
||||||
|
|
||||||
let version = Version::decode(&item_bytes).ok_or_message("Cannot decode Version")?;
|
let version = Version::decode(&item_bytes).ok_or_message("Cannot decode Version")?;
|
||||||
if !version.deleted.get() {
|
if !version.deleted.get() {
|
||||||
let object = self
|
let version_exists = match &version.backlink {
|
||||||
.garage
|
VersionBacklink::Object { bucket_id, key } => {
|
||||||
.object_table
|
let object = self.garage.object_table.get(&bucket_id, &key).await?;
|
||||||
.get(&version.bucket_id, &version.key)
|
match object {
|
||||||
.await?;
|
Some(o) => o.versions().iter().any(|x| {
|
||||||
let version_exists = match object {
|
x.uuid == version.uuid && x.state != ObjectVersionState::Aborted
|
||||||
Some(o) => o
|
}),
|
||||||
.versions()
|
None => false,
|
||||||
.iter()
|
}
|
||||||
.any(|x| x.uuid == version.uuid && x.state != ObjectVersionState::Aborted),
|
}
|
||||||
None => false,
|
VersionBacklink::MultipartUpload { upload_id } => {
|
||||||
|
let mpu = self.garage.mpu_table.get(&upload_id, &EmptyKey).await?;
|
||||||
|
match mpu {
|
||||||
|
Some(u) => !u.deleted.get(),
|
||||||
|
None => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
if !version_exists {
|
if !version_exists {
|
||||||
info!("Repair versions: marking version as deleted: {:?}", version);
|
info!("Repair versions: marking version as deleted: {:?}", version);
|
||||||
self.garage
|
self.garage
|
||||||
.version_table
|
.version_table
|
||||||
.insert(&Version::new(
|
.insert(&Version::new(version.uuid, version.backlink, true))
|
||||||
version.uuid,
|
|
||||||
version.bucket_id,
|
|
||||||
version.key,
|
|
||||||
true,
|
|
||||||
))
|
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue