Only produce warnings if files vanish during store
Some checks failed
ci/woodpecker/push/build Pipeline failed
ci/woodpecker/push/release Pipeline was successful

This commit is contained in:
Olivier 'reivilibre' 2023-05-26 23:43:23 +01:00
parent 32e514bd2e
commit 53886aad46
2 changed files with 31 additions and 19 deletions

View File

@ -6,6 +6,7 @@ use flume::{Receiver, RecvError, SendError, Sender};
use std::cmp::Reverse;
use std::collections::{BTreeMap, BTreeSet};
use std::fmt::Debug;
use std::io;
use std::io::Read;
use std::path::{Path, PathBuf};
use std::pin::Pin;
@ -14,7 +15,7 @@ use tokio::fs::File;
use tokio::runtime::Handle;
use tokio::task;
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_midlevel_crypto::chunk_id::{ChunkId, ChunkIdKey};
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(
file_path: &Path,
storing_state: &mut StoringState,
sbw: &mut StoringBloblogWriters,
) -> 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 size_of_file = mapped.as_ref().len();
let chunkref = storing_state.store_full_slice(mapped.as_ref(), sbw)?;

View File

@ -409,25 +409,25 @@ pub fn assemble_tree_from_scan_entries(
permissions,
size: _unverified_size_ignore,
} => {
let (content, size) = chunkings
if let Some((content, size)) = chunkings
.remove(&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'.
// That's fine. We'll patch this up later.
dirs.get_mut(parent_dir_name)
.context("bad PMap: parent not seen first")?
.insert(
child_name.to_owned(),
TreeNode::NormalFile {
mtime,
ownership,
permissions,
size,
content,
},
);
{
// 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.
dirs.get_mut(parent_dir_name)
.context("bad PMap: parent not seen first")?
.insert(
child_name.to_owned(),
TreeNode::NormalFile {
mtime,
ownership,
permissions,
size,
content,
},
);
}
}
ScanEntry::Directory {
ownership,