This commit is contained in:
Daniel 2023-12-15 20:24:18 +08:00
parent cf6895770c
commit 999a6b8606
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -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{}