From 0c653418a67fe960bb3126559fe77833faaa385c Mon Sep 17 00:00:00 2001 From: Lena Date: Sun, 23 Aug 2026 00:00:00 +0000 Subject: app: remove duplicated and dead code upgradeLegacy assembled every remote, folder and schedule twice: once as Remote and Folder objects to validate, and again as a parallel JSON tree to return. Build the objects and serialise them, and drop the dead endpointAllowed branch, the redundant pin emptiness test, and the excludes length pre-check that excludesAllowed already makes. atomicWrite existed verbatim in Config and Keys and was open-coded a third time in LastSync, which then reached into Config's companion for the bounded reader. The same bounded read was open-coded twice more, for the encrypted key and for an imported one. Both are plain file operations on the same private directory and belong in one place, with readText a thin wrapper over readBytes. Generating and importing an identity key ran the same twenty lines of worker thread, error capture, refresh, toast and dialog; only the action and two strings differed. rotateIfBig rotated at length >= MAX_BYTES, which line() already subsumes, and its only caller invoked it immediately before a line(). notifyError and notifyDeleted were the same builder twice. openSettings nested a try/catch and repeated one toast; take the candidates as a vararg. RemoteActivity.save defaulted its argument to current(), which validates and writes the status field, so the default hid that side effect from one of two callers. Dead on arrival: Outcome.deleted's default, which no caller omits; the rsa-sha2-* arms of hostKeyFile, since rsh prints PublicKey.Type() and an RSA host key is always ssh-rsa; and the limit <= 0 branch in SyncLog.text, which tail already handles and handled more accurately. The config recovery note is now written with an explicit charset like every other write here. --- app/src/test/java/invalid/lena/rsend/ConfigTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/src/test/java/invalid/lena') diff --git a/app/src/test/java/invalid/lena/rsend/ConfigTest.kt b/app/src/test/java/invalid/lena/rsend/ConfigTest.kt index e289afd..0f138bf 100644 --- a/app/src/test/java/invalid/lena/rsend/ConfigTest.kt +++ b/app/src/test/java/invalid/lena/rsend/ConfigTest.kt @@ -389,7 +389,7 @@ class ConfigTest { fun configInputIsBounded() { val oversized = ByteArray(Config.MAX_CONFIG_BYTES + 1) try { - Config.readText(ByteArrayInputStream(oversized), Config.MAX_CONFIG_BYTES) + readText(ByteArrayInputStream(oversized), Config.MAX_CONFIG_BYTES) throw AssertionError("oversized config accepted") } catch (_: IllegalArgumentException) { } -- cgit v1.2.3