Windows
This commit is contained in:
parent
33606e06e5
commit
253467c5e6
1 changed files with 25 additions and 25 deletions
|
@ -420,18 +420,19 @@ impl Fs for RealFs {
|
||||||
|
|
||||||
async fn remove_file(&self, path: &Path, options: RemoveOptions) -> Result<()> {
|
async fn remove_file(&self, path: &Path, options: RemoveOptions) -> Result<()> {
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
if let Ok(Some(metadata)) = self.metadata(path).await {
|
if let Ok(Some(metadata)) = self.metadata(path).await
|
||||||
if metadata.is_symlink && metadata.is_dir {
|
&& metadata.is_symlink
|
||||||
self.remove_dir(
|
&& metadata.is_dir
|
||||||
path,
|
{
|
||||||
RemoveOptions {
|
self.remove_dir(
|
||||||
recursive: false,
|
path,
|
||||||
ignore_if_not_exists: true,
|
RemoveOptions {
|
||||||
},
|
recursive: false,
|
||||||
)
|
ignore_if_not_exists: true,
|
||||||
.await?;
|
},
|
||||||
return Ok(());
|
)
|
||||||
}
|
.await?;
|
||||||
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
match smol::fs::remove_file(path).await {
|
match smol::fs::remove_file(path).await {
|
||||||
|
@ -766,24 +767,23 @@ impl Fs for RealFs {
|
||||||
let pending_paths: Arc<Mutex<Vec<PathEvent>>> = Default::default();
|
let pending_paths: Arc<Mutex<Vec<PathEvent>>> = Default::default();
|
||||||
let watcher = Arc::new(fs_watcher::FsWatcher::new(tx, pending_paths.clone()));
|
let watcher = Arc::new(fs_watcher::FsWatcher::new(tx, pending_paths.clone()));
|
||||||
|
|
||||||
if watcher.add(path).is_err() {
|
// If the path doesn't exist yet (e.g. settings.json), watch the parent dir to learn when it's created.
|
||||||
// If the path doesn't exist yet (e.g. settings.json), watch the parent dir to learn when it's created.
|
if watcher.add(path).is_err()
|
||||||
if let Some(parent) = path.parent() {
|
&& let Some(parent) = path.parent()
|
||||||
if let Err(e) = watcher.add(parent) {
|
&& let Err(e) = watcher.add(parent)
|
||||||
log::warn!("Failed to watch: {e}");
|
{
|
||||||
}
|
log::warn!("Failed to watch: {e}");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if path is a symlink and follow the target parent
|
// Check if path is a symlink and follow the target parent
|
||||||
if let Some(mut target) = self.read_link(path).await.ok() {
|
if let Some(mut target) = self.read_link(path).await.ok() {
|
||||||
// Check if symlink target is relative path, if so make it absolute
|
// Check if symlink target is relative path, if so make it absolute
|
||||||
if target.is_relative() {
|
if target.is_relative()
|
||||||
if let Some(parent) = path.parent() {
|
&& let Some(parent) = path.parent()
|
||||||
target = parent.join(target);
|
{
|
||||||
if let Ok(canonical) = self.canonicalize(&target).await {
|
target = parent.join(target);
|
||||||
target = SanitizedPath::from(canonical).as_path().to_path_buf();
|
if let Ok(canonical) = self.canonicalize(&target).await {
|
||||||
}
|
target = SanitizedPath::from(canonical).as_path().to_path_buf();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
watcher.add(&target).ok();
|
watcher.add(&target).ok();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue