suppress errors on file removal in SaveRatchet and LoadRatchets methods for improved error handling
Some checks failed
Go Build Multi-Platform / build (amd64, linux) (push) Failing after 35s
Go Build Multi-Platform / build (arm, freebsd) (push) Failing after 33s
Go Build Multi-Platform / build (arm, linux) (push) Failing after 33s
Go Build Multi-Platform / build (arm64, darwin) (push) Failing after 34s
Go Build Multi-Platform / build (arm, windows) (push) Failing after 36s
Go Build Multi-Platform / build (arm64, linux) (push) Failing after 30s
Go Build Multi-Platform / build (amd64, darwin) (push) Failing after 27s
Go Build Multi-Platform / build (amd64, freebsd) (push) Failing after 26s
Go Build Multi-Platform / build (amd64, windows) (push) Failing after 33s
Go Build Multi-Platform / build (arm64, freebsd) (push) Failing after 32s
Go Build Multi-Platform / build (arm64, windows) (push) Failing after 54s
Go Test Multi-Platform / Test (ubuntu-latest, arm64) (push) Successful in 45s
Go Build Multi-Platform / Create Release (push) Has been skipped
Go Test Multi-Platform / Test (ubuntu-latest, amd64) (push) Successful in 1m37s
Go Revive Lint / lint (push) Successful in 47s
Run Gosec / tests (push) Successful in 1m22s
Go Test Multi-Platform / Test (macos-latest, amd64) (push) Has been cancelled
Go Test Multi-Platform / Test (windows-latest, amd64) (push) Has been cancelled
Go Test Multi-Platform / Test (macos-latest, arm64) (push) Has been cancelled

This commit is contained in:
2025-11-21 12:45:40 -06:00
parent cfcdb62168
commit 0d2239be83

View File

@@ -100,7 +100,7 @@ func (m *Manager) SaveRatchet(identityHash []byte, ratchetKey []byte) error {
}
if err := os.Rename(outPath, finalPath); err != nil {
os.Remove(outPath)
_ = os.Remove(outPath)
return fmt.Errorf("failed to move ratchet file: %w", err)
}
@@ -136,7 +136,7 @@ func (m *Manager) LoadRatchets(identityHash []byte) (map[string][]byte, error) {
}
filePath := filepath.Join(ratchetDir, entry.Name())
data, err := os.ReadFile(filePath)
data, err := os.ReadFile(filePath) // #nosec G304 - reading from controlled directory
if err != nil {
debug.Log(debug.DEBUG_ERROR, "Failed to read ratchet file", "file", entry.Name(), "error", err)
continue
@@ -145,13 +145,13 @@ func (m *Manager) LoadRatchets(identityHash []byte) (map[string][]byte, error) {
var ratchetData RatchetData
if err := msgpack.Unmarshal(data, &ratchetData); err != nil {
debug.Log(debug.DEBUG_ERROR, "Corrupted ratchet data", "file", entry.Name(), "error", err)
os.Remove(filePath)
_ = os.Remove(filePath)
continue
}
if now > ratchetData.Received+expiry {
debug.Log(debug.DEBUG_VERBOSE, "Removing expired ratchet", "file", entry.Name())
os.Remove(filePath)
_ = os.Remove(filePath)
continue
}