Skip to content

fix: delete incorrect dir on import respack failure#780

Open
NuanRMxi wants to merge 3 commits intomainfrom
fix-delrespack
Open

fix: delete incorrect dir on import respack failure#780
NuanRMxi wants to merge 3 commits intomainfrom
fix-delrespack

Conversation

@NuanRMxi
Copy link
Copy Markdown
Member

fixed #777

Comment thread phira/src/scene/main.rs Outdated
Comment thread phira/src/scene/main.rs Outdated
@YuevUwU
Copy link
Copy Markdown
Contributor

YuevUwU commented Apr 27, 2026

Empty/Useless Subpath Safety Prevention

phira/prpr/src/dir.rs

Lines 46 to 56 in bf06cb6

#[inline]
pub fn create_dir_all(&self, p: impl AsRef<Path>) -> Result<()> {
std::fs::create_dir_all(self.join(p)?)?;
Ok(())
}
#[inline]
pub fn remove_dir_all(&self, p: impl AsRef<Path>) -> Result<()> {
std::fs::remove_dir_all(self.join(p)?)?;
Ok(())
}

Consider add empty p arg check: Check self.0 == self.join(p)?.
(".", "./", "" should use original std::fs, or phira::ensure)

If all usages are confirmed, just check it in join method. (if self.0 == path { bail!("empty/useless subpath") })

@NuanRMxi
Copy link
Copy Markdown
Member Author

Empty/Useless Subpath Safety Prevention

phira/prpr/src/dir.rs

Lines 46 to 56 in bf06cb6

#[inline]
pub fn create_dir_all(&self, p: impl AsRef<Path>) -> Result<()> {
std::fs::create_dir_all(self.join(p)?)?;
Ok(())
}
#[inline]
pub fn remove_dir_all(&self, p: impl AsRef<Path>) -> Result<()> {
std::fs::remove_dir_all(self.join(p)?)?;
Ok(())
}

Consider add empty p arg check: Check self.0 == self.join(p)?. (".", "./", "" should use original std::fs, or phira::ensure)

If all usages are confirmed, just check it in join method. (if self.0 == path { bail!("empty/useless subpath") })

可以加,但我懒了,还是尽量避免在一开始传参就传入错误信息就好,在这里检查有治标不治本的感觉,但是确实可能利于debug

NuanRMxi and others added 2 commits April 28, 2026 18:21
Co-authored-by: YuevUwU <96368079+YuevUwU@users.noreply.github.com>
Co-authored-by: YuevUwU <96368079+YuevUwU@users.noreply.github.com>
@YuevUwU
Copy link
Copy Markdown
Contributor

YuevUwU commented Apr 28, 2026

可以加,但我懒了,还是尽量避免在一开始传参就传入错误信息就好,在这里检查有治标不治本的感觉,但是确实可能利于debug

没关系,给Mivik看看

btw 重发一下

  • NOTICE: 现在 remove_dir_all 移到下面并不会显示两个 Dialog Box,而是只有 remove_dir_all 的报错,Log 里面的话两个 show_error 都是有的 (只修了Log)
  • dir_id 的实际功用是「已创建的文件夹ID」,若不嫌变数名长度,建议改成 created_dir_id 或更好的语义聚拢方式

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] All Respack will be Removed while importing Unexpected Respack since v0.7.0

2 participants