Only produce warnings if files vanish during store
This commit is contained in:
parent
32e514bd2e
commit
53886aad46
@ -6,6 +6,7 @@ use flume::{Receiver, RecvError, SendError, Sender};
|
|||||||
use std::cmp::Reverse;
|
use std::cmp::Reverse;
|
||||||
use std::collections::{BTreeMap, BTreeSet};
|
use std::collections::{BTreeMap, BTreeSet};
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
|
use std::io;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
@ -14,7 +15,7 @@ use tokio::fs::File;
|
|||||||
use tokio::runtime::Handle;
|
use tokio::runtime::Handle;
|
||||||
use tokio::task;
|
use tokio::task;
|
||||||
use tokio::task::JoinSet;
|
use tokio::task::JoinSet;
|
||||||
use tracing::{debug, error, info_span, Instrument};
|
use tracing::{debug, error, info_span, warn, Instrument};
|
||||||
use yama_localcache::StoreConnection;
|
use yama_localcache::StoreConnection;
|
||||||
use yama_midlevel_crypto::chunk_id::{ChunkId, ChunkIdKey};
|
use yama_midlevel_crypto::chunk_id::{ChunkId, ChunkIdKey};
|
||||||
use yama_pile::bloblogs::BloblogWriter;
|
use yama_pile::bloblogs::BloblogWriter;
|
||||||
@ -275,12 +276,23 @@ impl StoringState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Stores a file, returning Ok(Some(...)) if fine, Ok(None) if the file doesn't exist (vanished)
|
||||||
|
/// or Err(...) for any other error.
|
||||||
async fn store_file(
|
async fn store_file(
|
||||||
file_path: &Path,
|
file_path: &Path,
|
||||||
storing_state: &mut StoringState,
|
storing_state: &mut StoringState,
|
||||||
sbw: &mut StoringBloblogWriters,
|
sbw: &mut StoringBloblogWriters,
|
||||||
) -> eyre::Result<Option<(RecursiveChunkRef, u64)>> {
|
) -> eyre::Result<Option<(RecursiveChunkRef, u64)>> {
|
||||||
let file = File::open(file_path).await?.into_std().await;
|
let file = match File::open(file_path).await {
|
||||||
|
Ok(file) => file.into_std().await,
|
||||||
|
Err(err) if err.kind() == io::ErrorKind::NotFound => {
|
||||||
|
warn!("file vanished: {file_path:?}");
|
||||||
|
return Ok(None);
|
||||||
|
}
|
||||||
|
Err(other) => {
|
||||||
|
bail!("error storing {file_path:?}: {other:?}");
|
||||||
|
}
|
||||||
|
};
|
||||||
let mapped = unsafe { memmap2::Mmap::map(&file) }?;
|
let mapped = unsafe { memmap2::Mmap::map(&file) }?;
|
||||||
let size_of_file = mapped.as_ref().len();
|
let size_of_file = mapped.as_ref().len();
|
||||||
let chunkref = storing_state.store_full_slice(mapped.as_ref(), sbw)?;
|
let chunkref = storing_state.store_full_slice(mapped.as_ref(), sbw)?;
|
||||||
|
@ -409,25 +409,25 @@ pub fn assemble_tree_from_scan_entries(
|
|||||||
permissions,
|
permissions,
|
||||||
size: _unverified_size_ignore,
|
size: _unverified_size_ignore,
|
||||||
} => {
|
} => {
|
||||||
let (content, size) = chunkings
|
if let Some((content, size)) = chunkings
|
||||||
.remove(&key_string)
|
.remove(&key_string)
|
||||||
.with_context(|| format!("bad chunkings PMap: missing entry: {key_string:?}"))?
|
.with_context(|| format!("bad chunkings PMap: missing entry: {key_string:?}"))?
|
||||||
.unwrap(); // TODO
|
{
|
||||||
|
// note: for the root, this inserts the root file entry as a child called "" within a fake root 'directory'.
|
||||||
// note: for the root, this inserts the root file entry as a child called "" within a fake root 'directory'.
|
// That's fine. We'll patch this up later.
|
||||||
// That's fine. We'll patch this up later.
|
dirs.get_mut(parent_dir_name)
|
||||||
dirs.get_mut(parent_dir_name)
|
.context("bad PMap: parent not seen first")?
|
||||||
.context("bad PMap: parent not seen first")?
|
.insert(
|
||||||
.insert(
|
child_name.to_owned(),
|
||||||
child_name.to_owned(),
|
TreeNode::NormalFile {
|
||||||
TreeNode::NormalFile {
|
mtime,
|
||||||
mtime,
|
ownership,
|
||||||
ownership,
|
permissions,
|
||||||
permissions,
|
size,
|
||||||
size,
|
content,
|
||||||
content,
|
},
|
||||||
},
|
);
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
ScanEntry::Directory {
|
ScanEntry::Directory {
|
||||||
ownership,
|
ownership,
|
||||||
|
Loading…
Reference in New Issue
Block a user