feat: delete old file when updating version with new file
If file_path is different from existing file, remove the old file Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -453,6 +453,18 @@ func handleUpdateVersionGlobal(c *gin.Context) {
|
|||||||
|
|
||||||
log.Printf("[DEBUG] Updates map: %+v\n", updates)
|
log.Printf("[DEBUG] Updates map: %+v\n", updates)
|
||||||
|
|
||||||
|
// 如果文件被更新,删除旧文件
|
||||||
|
if req.FilePath != "" && req.FilePath != version.FilePath {
|
||||||
|
oldFilePath := filepath.Join(".", version.FilePath)
|
||||||
|
if _, err := os.Stat(oldFilePath); err == nil {
|
||||||
|
if err := os.Remove(oldFilePath); err != nil {
|
||||||
|
log.Printf("[WARN] Failed to remove old file %s: %v\n", oldFilePath, err)
|
||||||
|
} else {
|
||||||
|
log.Printf("[INFO] Removed old file: %s\n", oldFilePath)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if len(updates) == 0 {
|
if len(updates) == 0 {
|
||||||
response.Success(c, nil)
|
response.Success(c, nil)
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user