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
+3 -3
View File
@@ -31,9 +31,9 @@ func GetRemoteDataFromServer(clientDeviceID string) {
//// server time
fetchResp.ServerTime = time.Now().Unix()
//// deletions
for _, deletion := range deletionsList {
for i := range deletionsList {
// perform deletion if it is relevant to the current client device
affectedIDVanityPath := strings.Split(deletion.Name(), global.FSSpace)
affectedIDVanityPath := strings.Split(deletionsList[i].Name(), global.FSSpace)
if affectedIDVanityPath[0] == clientDeviceID {
var isAgeFile bool
if affectedIDVanityPath[1] == "age" {
@@ -42,7 +42,7 @@ func GetRemoteDataFromServer(clientDeviceID string) {
fetchResp.Deletions = append(fetchResp.Deletions, synccommon.Deletion{VanityPath: strings.ReplaceAll(affectedIDVanityPath[2], global.FSPath, "/"), IsAgeFile: isAgeFile})
// assume successful client deletion and remove deletions file (if assumption is somehow false, worst case scenario is that the client will re-upload the deleted entry)
if err = os.RemoveAll(global.CfgDir + global.PathSeparator + "deletions" + global.PathSeparator + deletion.Name()); err != nil {
if err = os.RemoveAll(global.CfgDir + global.PathSeparator + "deletions" + global.PathSeparator + deletionsList[i].Name()); err != nil {
fmt.Printf("{\"errMsg\":\"%s\"}", err.Error())
return
}