Skip to content

Commit 73e5ed8

Browse files
committed
terminate immediately if store is invalid
1 parent 00a18d9 commit 73e5ed8

3 files changed

Lines changed: 13 additions & 5 deletions

File tree

src/fs/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ where
100100

101101
let session = AsyncSession::mount(mountpoint, options).await?;
102102

103-
104103
// release here
105104
while let Some(req) = session.next_request().await? {
106105
let fs = self.clone();

src/pack.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::fungi::meta::{Ino, Inode};
22
use crate::fungi::{Error, Result, Writer};
3-
use crate::store::{BlockStore, Store};
3+
use crate::store::{BlockStore, Error as StoreError, Store};
44
use anyhow::Context;
55
use futures::lock::Mutex;
66
use std::collections::LinkedList;
@@ -19,7 +19,7 @@ type FailuresList = Arc<Mutex<Vec<(PathBuf, Error)>>>;
1919
#[derive(Debug)]
2020
struct Item(Ino, PathBuf, OsString, Metadata);
2121
/// creates an FL from the given root location. It takes ownership of the writer because
22-
/// it's logically incorrect to store multiple filessytem in the same FL.
22+
/// it's logically incorrect to store multiple filesystem in the same FL.
2323
/// All file chunks will then be uploaded to the provided store
2424
///
2525
pub async fn pack<P: Into<PathBuf>, S: Store>(
@@ -239,7 +239,16 @@ where
239239
}
240240

241241
// write block to remote store
242-
let block = self.store.set(&self.buffer[..size]).await?;
242+
let store_result = self.store.set(&self.buffer[..size]).await;
243+
244+
if let Err(store_err) = &store_result {
245+
if let StoreError::Other(_) = store_err {
246+
log::error!("failed to upload file {}: {:#}", path.display(), store_err);
247+
std::process::exit(1); // Force immediate termination
248+
}
249+
}
250+
251+
let block = store_result.map_err(Error::Store)?;
243252

244253
// write block info to meta
245254
self.writer.block(ino, &block.id, &block.key).await?;

src/server/block_handlers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::server::{
1313
config::AppState,
1414
db::DB,
1515
models::Block,
16-
response::{BlockUploadedResponse, ResponseError, ResponseResult},
16+
response::{ResponseError, ResponseResult},
1717
};
1818
use serde::{Deserialize, Serialize};
1919
use utoipa::ToSchema;

0 commit comments

Comments
 (0)