Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2023-09-26 11:29:28 +08:00
commit 67be62d54d
5 changed files with 40 additions and 11 deletions

View file

@ -24,6 +24,7 @@ Below are the detailed changes in this version.
* [Improve data sync network connectivity check](https://github.com/siyuan-note/siyuan/issues/9251) * [Improve data sync network connectivity check](https://github.com/siyuan-note/siyuan/issues/9251)
* [Improve the handling of inline-code containing `|` in the table](https://github.com/siyuan-note/siyuan/issues/9252) * [Improve the handling of inline-code containing `|` in the table](https://github.com/siyuan-note/siyuan/issues/9252)
* [Improve thematic break editing](https://github.com/siyuan-note/siyuan/issues/9259) * [Improve thematic break editing](https://github.com/siyuan-note/siyuan/issues/9259)
* [Improve table row insertion when using the fixed header](https://github.com/siyuan-note/siyuan/issues/9265)
### Bugfix ### Bugfix

View file

@ -24,6 +24,7 @@
* [改進資料同步網路連結性檢查](https://github.com/siyuan-note/siyuan/issues/9251) * [改進資料同步網路連結性檢查](https://github.com/siyuan-note/siyuan/issues/9251)
* [改進表格中包含 `|` 時行級程式碼的處理](https://github.com/siyuan-note/siyuan/issues/9252) * [改進表格中包含 `|` 時行級程式碼的處理](https://github.com/siyuan-note/siyuan/issues/9252)
* [改進分隔線編輯](https://github.com/siyuan-note/siyuan/issues/9259) * [改進分隔線編輯](https://github.com/siyuan-note/siyuan/issues/9259)
* [使用固定標題時改進表格行插入](https://github.com/siyuan-note/siyuan/issues/9265)
### 修復缺陷 ### 修復缺陷

View file

@ -24,6 +24,7 @@
* [改进数据同步网络连通性检查](https://github.com/siyuan-note/siyuan/issues/9251) * [改进数据同步网络连通性检查](https://github.com/siyuan-note/siyuan/issues/9251)
* [改进表格中包含 `|` 时行级代码的处理](https://github.com/siyuan-note/siyuan/issues/9252) * [改进表格中包含 `|` 时行级代码的处理](https://github.com/siyuan-note/siyuan/issues/9252)
* [改进分隔线编辑](https://github.com/siyuan-note/siyuan/issues/9259) * [改进分隔线编辑](https://github.com/siyuan-note/siyuan/issues/9259)
* [使用固定标题时改进表格行插入](https://github.com/siyuan-note/siyuan/issues/9265)
### 修复缺陷 ### 修复缺陷

View file

@ -663,6 +663,37 @@ func UnusedAssets() (ret []string) {
continue continue
} }
} }
// 排除数据库中引用的资源文件
storageAvDir := filepath.Join(util.DataDir, "storage", "av")
if gulu.File.IsDir(storageAvDir) {
entries, readErr := os.ReadDir(storageAvDir)
if nil != readErr {
logging.LogErrorf("read dir [%s] failed: %s", storageAvDir, readErr)
err = readErr
return
}
for _, entry := range entries {
if !strings.HasSuffix(entry.Name(), ".json") || !ast.IsNodeIDPattern(strings.TrimSuffix(entry.Name(), ".json")) {
continue
}
data, readDataErr := filelock.ReadFile(filepath.Join(util.DataDir, "storage", "av", entry.Name()))
if nil != readDataErr {
logging.LogErrorf("read file [%s] failed: %s", entry.Name(), readDataErr)
err = readDataErr
return
}
for asset, _ := range assetsPathMap {
if bytes.Contains(data, []byte(asset)) {
toRemoves = append(toRemoves, asset)
}
}
}
}
for _, toRemove := range toRemoves { for _, toRemove := range toRemoves {
delete(assetsPathMap, toRemove) delete(assetsPathMap, toRemove)
} }

View file

@ -260,18 +260,13 @@ func ImportSY(zipPath, boxID, toPath string) (err error) {
ial := parse.IAL2Map(n.KramdownIAL) ial := parse.IAL2Map(n.KramdownIAL)
for k, v := range ial { for k, v := range ial {
if strings.HasPrefix(k, NodeAttrNamePrefixAvKey) || strings.HasPrefix(k, NodeAttrNameAvs) { if strings.HasPrefix(k, NodeAttrNamePrefixAvKey) || strings.HasPrefix(k, NodeAttrNameAvs) {
newKey, newVal := k, v
for oldAvID, newAvID := range avIDs { for oldAvID, newAvID := range avIDs {
newKey := strings.ReplaceAll(k, oldAvID, newAvID) newKey = strings.ReplaceAll(newKey, oldAvID, newAvID)
newVal := strings.ReplaceAll(v, oldAvID, newAvID) newVal = strings.ReplaceAll(newVal, oldAvID, newAvID)
if newKey != k { }
n.SetIALAttr(newKey, v)
n.RemoveIALAttr(k) n.RemoveIALAttr(k)
k = newKey n.SetIALAttr(newKey, newVal)
}
if newVal != v {
n.SetIALAttr(k, newVal)
}
}
} }
} }