fix(marmot): log ignored File.delete results in AndroidPushStateStore

Sonar flagged both delete() calls for discarding the Boolean result.
save() now warns when the temp file left behind by a failed rename
cannot be removed, and clear() only deletes a file that exists and
warns when the delete is refused.
This commit is contained in:
davotoula
2026-09-11 14:48:05 +02:00
parent d669bcc745
commit a4b68af778
@@ -90,7 +90,9 @@ class AndroidPushStateStore(
temp.writeText(state)
if (!temp.renameTo(target)) {
target.writeText(state)
temp.delete()
if (!temp.delete()) {
Log.w(TAG) { "could not remove temp push state file ${temp.name}" }
}
}
} catch (e: Exception) {
Log.w(TAG, "could not persist push state for $nostrGroupId: ${e.message}", e)
@@ -102,7 +104,10 @@ class AndroidPushStateStore(
withContext(Dispatchers.IO) {
mutex.withLock {
try {
file(nostrGroupId)?.delete()
val target = file(nostrGroupId)?.takeIf { it.exists() }
if (target != null && !target.delete()) {
Log.w(TAG) { "could not delete push state for $nostrGroupId" }
}
} catch (e: Exception) {
Log.w(TAG, "could not clear push state for $nostrGroupId: ${e.message}", e)
}