Why was I doing that, it looks bad.

This commit is contained in:
comp500 2019-04-26 17:19:55 +01:00
parent d7e916e558
commit 2f3b80f251
No known key found for this signature in database
GPG Key ID: 214C822FFEC586B5

View File

@ -1,4 +1,5 @@
package core package core
import ( import (
"crypto/sha256" "crypto/sha256"
"encoding/hex" "encoding/hex"
@ -53,13 +54,16 @@ func (in *Index) RemoveFile(path string) error {
if err != nil { if err != nil {
return err return err
} }
newFiles := in.Files[:0]
for _, v := range in.Files { i := 0
if filepath.Clean(v.File) != relPath { for _, file := range in.Files {
newFiles = append(newFiles, v) if filepath.Clean(file.File) != relPath {
// Keep file, as it doesn't match
in.Files[i] = file
i++
} }
} }
in.Files = newFiles in.Files = in.Files[:i]
return nil return nil
} }
@ -175,6 +179,7 @@ func (in *Index) Refresh() error {
} }
} }
in.Files = in.Files[:i] in.Files = in.Files[:i]
in.resortIndex() in.resortIndex()
return nil return nil
} }