mirror of
				https://github.com/packwiz/packwiz.git
				synced 2025-10-31 18:44:33 +01:00 
			
		
		
		
	Significantly improve refreshing performance
Looping through every file on every file update *and* cleaning + fromslash is sloww with many files (ideally, we'd have a map to look up the file, but this is already significantly faster)
This commit is contained in:
		| @@ -84,8 +84,10 @@ func (in *Index) updateFileHashGiven(path, format, hash string, mod bool) error | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	slashPath := filepath.ToSlash(relPath) | ||||
| 	// TODO: make this not a linear scan for every file update | ||||
| 	for k, v := range in.Files { | ||||
| 		if filepath.Clean(filepath.FromSlash(v.File)) == relPath { | ||||
| 		if v.File == slashPath { | ||||
| 			found = true | ||||
| 			// Update hash | ||||
| 			in.Files[k].Hash = hash | ||||
| @@ -96,15 +98,14 @@ func (in *Index) updateFileHashGiven(path, format, hash string, mod bool) error | ||||
| 			} | ||||
| 			// Mark this file as found | ||||
| 			in.Files[k].fileExistsTemp = true | ||||
| 			// Clean up path if it's untidy | ||||
| 			in.Files[k].File = filepath.ToSlash(relPath) | ||||
| 			in.Files[k].File = slashPath | ||||
| 			// Don't break out of loop, as there may be aliased versions that | ||||
| 			// also need to be updated | ||||
| 		} | ||||
| 	} | ||||
| 	if !found { | ||||
| 		newFile := IndexFile{ | ||||
| 			File:           filepath.ToSlash(relPath), | ||||
| 			File:           slashPath, | ||||
| 			Hash:           hash, | ||||
| 			fileExistsTemp: true, | ||||
| 		} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user