mirror of
				https://github.com/osmarks/mycorrhiza.git
				synced 2025-10-31 15:43:00 +00:00 
			
		
		
		
	Fix the renaming bug
This commit is contained in:
		
							
								
								
									
										7
									
								
								hypha.go
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								hypha.go
									
									
									
									
									
								
							| @@ -8,7 +8,7 @@ import ( | ||||
| 	"mime/multipart" | ||||
| 	"os" | ||||
| 	"path/filepath" | ||||
| 	"strings" | ||||
| 	"regexp" | ||||
|  | ||||
| 	"github.com/bouncepaw/mycorrhiza/history" | ||||
| 	"github.com/bouncepaw/mycorrhiza/hyphae" | ||||
| @@ -88,7 +88,7 @@ func uploadHelp(hop *history.HistoryOp, hyphaName, ext string, data []byte, u *u | ||||
| 		hyphae.IncrementCount() | ||||
| 	} | ||||
| 	*originalFullPath = fullPath | ||||
| 	if hop.Type == history.TypeEditText && !history.FileChanged(fullPath) { | ||||
| 	if isOld && hop.Type == history.TypeEditText && !history.FileChanged(fullPath) { | ||||
| 		return hop.Abort() | ||||
| 	} | ||||
| 	return hop.WithFiles(fullPath). | ||||
| @@ -195,8 +195,9 @@ func relocateHyphaData(hyphaNames []string, replaceName func(string) string) { | ||||
| // RenameHypha renames hypha from old name `hyphaName` to `newName` and makes a history record about that. If `recursive` is `true`, its subhyphae will be renamed the same way. | ||||
| func RenameHypha(hyphaName, newName string, recursive bool, u *user.User) *history.HistoryOp { | ||||
| 	var ( | ||||
| 		re          = regexp.MustCompile(`(?i)` + hyphaName) | ||||
| 		replaceName = func(str string) string { | ||||
| 			return strings.Replace(str, hyphaName, newName, 1) | ||||
| 			return re.ReplaceAllString(CanonicalName(str), newName) | ||||
| 		} | ||||
| 		hyphaNames     = findHyphaeToRename(hyphaName, recursive) | ||||
| 		renameMap, err = renamingPairs(hyphaNames, replaceName) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 bouncepaw
					bouncepaw