Only use index when ranging over slices of structs

This commit is contained in:
2026-02-09 21:28:26 -05:00
parent 7ecd143b81
commit 273e86d97e
4 changed files with 20 additions and 20 deletions
+4 -4
View File
@@ -95,17 +95,17 @@ func ShearLocal(vanityPath, clientDeviceID string, onlyShearAgeFile bool) (strin
// add the sheared vanityPath to the deletions list (if running on a server)
if onServer {
for _, device := range deviceIDList {
if device.Name() != clientDeviceID {
for i := range deviceIDList {
if deviceIDList[i].Name() != clientDeviceID {
if !onlyShearAgeFile {
f, err := os.OpenFile(global.CfgDir+global.PathSeparator+"deletions"+global.PathSeparator+device.Name()+global.FSSpace+"entry"+global.FSSpace+strings.ReplaceAll(vanityPath, "/", global.FSPath), os.O_CREATE|os.O_WRONLY, 0600)
f, err := os.OpenFile(global.CfgDir+global.PathSeparator+"deletions"+global.PathSeparator+deviceIDList[i].Name()+global.FSSpace+"entry"+global.FSSpace+strings.ReplaceAll(vanityPath, "/", global.FSPath), os.O_CREATE|os.O_WRONLY, 0600)
if err != nil {
// failure to add the target to the deletions list will exit the program and result in a client re-uploading the target (non-critical)
return "", false, err
}
_ = f.Close() // error ignored; if the file could be created, it can probably be closed
}
f, err := os.OpenFile(global.CfgDir+global.PathSeparator+"deletions"+global.PathSeparator+device.Name()+global.FSSpace+"age"+global.FSSpace+strings.ReplaceAll(vanityPath, "/", global.FSPath), os.O_CREATE|os.O_WRONLY, 0600)
f, err := os.OpenFile(global.CfgDir+global.PathSeparator+"deletions"+global.PathSeparator+deviceIDList[i].Name()+global.FSSpace+"age"+global.FSSpace+strings.ReplaceAll(vanityPath, "/", global.FSPath), os.O_CREATE|os.O_WRONLY, 0600)
if err != nil {
// failure to add the target to the deletions list will exit the program and result in a client re-uploading the target (non-critical)
return "", false, err