Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

add context to errors in syncdir #995

Merged
merged 1 commit into from
Jun 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/agent/onefuzz/src/blob/url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ impl BlobContainerUrl {
pub fn url(&self) -> Result<Url> {
match self {
Self::BlobContainer(url) => Ok(url.clone()),
Self::Path(p) => Ok(Url::from_file_path(p).map_err(|_| anyhow!("invalid path"))?),
Self::Path(p) => Ok(Url::from_file_path(p)
bmc-msft marked this conversation as resolved.
Show resolved Hide resolved
.map_err(|err| anyhow!("invalid path. path:{} error:{:?}", p.display(), err))?),
}
}

Expand Down
12 changes: 10 additions & 2 deletions src/agent/onefuzz/src/syncdir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@ pub struct SyncedDir {
impl SyncedDir {
pub fn remote_url(&self) -> Result<BlobContainerUrl> {
let url = self.remote_path.clone().unwrap_or(BlobContainerUrl::new(
Url::from_file_path(self.local_path.clone()).map_err(|_| anyhow!("invalid path"))?,
Url::from_file_path(self.local_path.clone()).map_err(|err| {
anyhow!(
"invalid path: {} error:{:?}",
self.local_path.display(),
err
)
})?,
)?);
Ok(url)
}
Expand Down Expand Up @@ -89,7 +95,9 @@ impl SyncedDir {

pub async fn init(&self) -> Result<()> {
if let Some(remote_path) = self.remote_path.clone().and_then(|u| u.as_file_path()) {
fs::create_dir_all(remote_path).await?;
fs::create_dir_all(&remote_path).await.with_context(|| {
format!("unable to create directory: {}", remote_path.display())
})?;
}

match fs::metadata(&self.local_path).await {
Expand Down