mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-22 17:11:43 +03:00
handle strip_prefix error
This commit is contained in:
parent
4bfd84ee86
commit
13da9d8f87
@ -59,9 +59,16 @@ impl Dispatcher {
|
||||
continue;
|
||||
}
|
||||
for file_path in event.paths {
|
||||
let relative_file_path =
|
||||
file_path.strip_prefix(&self.project_path).unwrap();
|
||||
if let Err(e) = rtx.send(relative_file_path.to_path_buf()) {
|
||||
if let Err(e) = file_path
|
||||
.strip_prefix(&self.project_path)
|
||||
.with_context(|| {
|
||||
format!(
|
||||
"failed to striprefix from file path: {}",
|
||||
file_path.display()
|
||||
)
|
||||
})
|
||||
.map(|relative_file_path| rtx.send(relative_file_path.to_path_buf()))
|
||||
{
|
||||
log::error!(
|
||||
"{}: failed to send file change event: {:#}",
|
||||
self.project_id,
|
||||
|
@ -1,9 +1,10 @@
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use anyhow::Result;
|
||||
use walkdir::WalkDir;
|
||||
|
||||
// Returns an ordered list of relative paths for files inside a directory recursively.
|
||||
pub fn list_files<P: AsRef<Path>>(dir_path: P) -> Result<Vec<PathBuf>, std::io::Error> {
|
||||
pub fn list_files<P: AsRef<Path>>(dir_path: P) -> Result<Vec<PathBuf>> {
|
||||
let mut files = vec![];
|
||||
let dir_path = dir_path.as_ref();
|
||||
if !dir_path.exists() {
|
||||
@ -13,7 +14,7 @@ pub fn list_files<P: AsRef<Path>>(dir_path: P) -> Result<Vec<PathBuf>, std::io::
|
||||
let entry = entry?;
|
||||
if entry.file_type().is_file() {
|
||||
let path = entry.path();
|
||||
let path = path.strip_prefix(dir_path).unwrap();
|
||||
let path = path.strip_prefix(dir_path)?;
|
||||
let path = path.to_path_buf();
|
||||
files.push(path);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user