This commit is contained in:
Daniel 2025-03-28 20:07:09 +08:00
parent 06417acc1f
commit f43699b2c4
No known key found for this signature in database
GPG Key ID: 86211BA83DF03017

View File

@ -649,9 +649,16 @@ func RenameAsset(oldPath, newName string) (newPath string, err error) {
}
newName = util.AssetName(newName + filepath.Ext(oldPath))
newPath = "assets/" + newName
if err = filelock.Copy(filepath.Join(util.DataDir, oldPath), filepath.Join(util.DataDir, newPath)); err != nil {
logging.LogErrorf("copy asset [%s] failed: %s", oldPath, err)
parentDir := path.Dir(oldPath)
newPath = path.Join(parentDir, newName)
oldAbsPath, getErr := GetAssetAbsPath(oldPath)
if getErr != nil {
logging.LogErrorf("get asset [%s] abs path failed: %s", oldPath, getErr)
return
}
newAbsPath := filepath.Join(filepath.Dir(oldAbsPath), newName)
if err = filelock.Copy(oldAbsPath, newAbsPath); err != nil {
logging.LogErrorf("copy asset [%s] failed: %s", oldAbsPath, err)
return
}