Fix panic while trying to remove '.'

This commit is contained in:
Michael Zhang 2020-03-11 03:06:47 -05:00
parent 9fea7bb655
commit e3e065d5b7
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B

View file

@ -66,8 +66,9 @@ pub fn put(options: PutOptions) -> Result<()> {
// don't allow deleting '.' or '..'
let current_dir = env::current_dir()?;
ensure!(
!(path.as_path() == current_dir.as_path()
|| (current_dir.parent().is_some() && path == current_dir.parent().unwrap())),
!(utils::into_absolute(&path)? == current_dir.as_path()
|| (current_dir.parent().is_some()
&& utils::into_absolute(&path)? == current_dir.parent().unwrap())),
Error::CannotTrashDotDirs
);