mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 23:20:13 +01:00
🎨 Improve removing unused assets
This commit is contained in:
parent
258d55b41f
commit
ba9f41aa35
1 changed files with 10 additions and 5 deletions
|
|
@ -521,17 +521,19 @@ func RemoveUnusedAssets() (ret []string) {
|
||||||
sql.BatchRemoveAssetsQueue(hashes)
|
sql.BatchRemoveAssetsQueue(hashes)
|
||||||
|
|
||||||
for _, unusedAsset := range unusedAssets {
|
for _, unusedAsset := range unusedAssets {
|
||||||
if unusedAsset = filepath.Join(util.DataDir, unusedAsset); filelock.IsExist(unusedAsset) {
|
absPath := filepath.Join(util.DataDir, unusedAsset)
|
||||||
info, statErr := os.Stat(unusedAsset)
|
if filelock.IsExist(absPath) {
|
||||||
|
info, statErr := os.Stat(absPath)
|
||||||
if statErr == nil {
|
if statErr == nil {
|
||||||
size += info.Size()
|
size += info.Size()
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := filelock.Remove(unusedAsset); err != nil {
|
if err := filelock.Remove(absPath); err != nil {
|
||||||
logging.LogErrorf("remove unused asset [%s] failed: %s", unusedAsset, err)
|
logging.LogErrorf("remove unused asset [%s] failed: %s", absPath, err)
|
||||||
}
|
}
|
||||||
|
util.RemoveAssetText(unusedAsset)
|
||||||
}
|
}
|
||||||
ret = append(ret, unusedAsset)
|
ret = append(ret, absPath)
|
||||||
}
|
}
|
||||||
if 0 < len(ret) {
|
if 0 < len(ret) {
|
||||||
IncSync()
|
IncSync()
|
||||||
|
|
@ -569,6 +571,9 @@ func RemoveUnusedAsset(p string) (ret string) {
|
||||||
logging.LogErrorf("remove unused asset [%s] failed: %s", absPath, err)
|
logging.LogErrorf("remove unused asset [%s] failed: %s", absPath, err)
|
||||||
}
|
}
|
||||||
ret = absPath
|
ret = absPath
|
||||||
|
|
||||||
|
util.RemoveAssetText(p)
|
||||||
|
|
||||||
IncSync()
|
IncSync()
|
||||||
|
|
||||||
indexHistoryDir(filepath.Base(historyDir), util.NewLute())
|
indexHistoryDir(filepath.Base(historyDir), util.NewLute())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue