Skip to content

Commit f1bbd6c

Browse files
committed
DRY entity is dead error
1 parent dc40545 commit f1bbd6c

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/store/fs.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ impl HashSpecificCommand for ExportPathMsg {
731731
async fn on_error(self, arg: SpawnArg<EmParams>) {
732732
let err = match arg {
733733
SpawnArg::Busy => io::ErrorKind::ResourceBusy.into(),
734-
SpawnArg::Dead => io::Error::other("entity is dead"),
734+
SpawnArg::Dead => err_entity_dead(),
735735
_ => unreachable!(),
736736
};
737737
self.tx
@@ -747,7 +747,7 @@ impl HashSpecificCommand for ExportBaoMsg {
747747
async fn on_error(self, arg: SpawnArg<EmParams>) {
748748
let err = match arg {
749749
SpawnArg::Busy => io::ErrorKind::ResourceBusy.into(),
750-
SpawnArg::Dead => io::Error::other("entity is dead"),
750+
SpawnArg::Dead => err_entity_dead(),
751751
_ => unreachable!(),
752752
};
753753
self.tx
@@ -763,7 +763,7 @@ impl HashSpecificCommand for ExportRangesMsg {
763763
async fn on_error(self, arg: SpawnArg<EmParams>) {
764764
let err = match arg {
765765
SpawnArg::Busy => io::ErrorKind::ResourceBusy.into(),
766-
SpawnArg::Dead => io::Error::other("entity is dead"),
766+
SpawnArg::Dead => err_entity_dead(),
767767
_ => unreachable!(),
768768
};
769769
self.tx
@@ -779,7 +779,7 @@ impl HashSpecificCommand for ImportBaoMsg {
779779
async fn on_error(self, arg: SpawnArg<EmParams>) {
780780
let err = match arg {
781781
SpawnArg::Busy => io::ErrorKind::ResourceBusy.into(),
782-
SpawnArg::Dead => io::Error::other("entity is dead"),
782+
SpawnArg::Dead => err_entity_dead(),
783783
_ => unreachable!(),
784784
};
785785
self.tx.send(Err(api::Error::from(err))).await.ok();
@@ -798,13 +798,17 @@ impl HashSpecificCommand for (TempTag, ImportEntryMsg) {
798798
async fn on_error(self, arg: SpawnArg<EmParams>) {
799799
let err = match arg {
800800
SpawnArg::Busy => io::ErrorKind::ResourceBusy.into(),
801-
SpawnArg::Dead => io::Error::other("entity is dead"),
801+
SpawnArg::Dead => err_entity_dead(),
802802
_ => unreachable!(),
803803
};
804804
self.1.tx.send(AddProgressItem::Error(err)).await.ok();
805805
}
806806
}
807807

808+
fn err_entity_dead() -> io::Error {
809+
io::Error::other("entity is dead")
810+
}
811+
808812
struct RtWrapper(Option<tokio::runtime::Runtime>);
809813

810814
impl From<tokio::runtime::Runtime> for RtWrapper {

0 commit comments

Comments
 (0)