mirror of
https://github.com/packwiz/packwiz.git
synced 2025-04-19 13:06:30 +02: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:
parent
8d50b97356
commit
37cc68a9f7
@ -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,
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user