Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: Create doc failed on non-Windows https://github.com/siyuan-note/siyuan/issues/9890

Daniel999a6b8606ad
diff --git a/kernel/model/box.go b/kernel/model/box.go
index 0b37bfad97..e3f8dc4352 100644
--- a/kernel/model/box.go
+++ b/kernel/model/box.go
@@ -257,6 +257,16 @@ func (box *Box) Ls(p string) (ret []*FileInfo, totals int, err error) {
if util.IsReservedFilename(name) {
continue
}
+ if strings.HasSuffix(name, ".tmp") {
+ // 移除写入失败时产生的并且早于 30 分钟前的临时文件,近期创建的临时文件可能正在写入中
+ removePath := filepath.Join(util.DataDir, box.ID, p, name)
+ if info.ModTime().Before(time.Now().Add(-30 * time.Minute)) {
+ if removeErr := os.Remove(removePath); nil != removeErr {
+ logging.LogWarnf("remove tmp file [%s] failed: %s", removePath, removeErr)
+ }
+ }
+ continue
+ }
totals += 1
fi := &FileInfo{}