refactor(dns-cache): drop legacy DNS migration paths

Removes the json-blob and SharedPreferences reclaim routines now that
the binary format is the first persisted shape — no users carry the
older blobs.
This commit is contained in:
Claude
2026-05-16 14:30:09 +00:00
parent 435aa3e7df
commit 424d750aea
3 changed files with 0 additions and 25 deletions
@@ -559,9 +559,6 @@ class AppModules(
// once restored, every previously-seen host hits the stale-while-revalidate path
// instead of blocking on getaddrinfo.
applicationIOScope.launch {
// One-shot reclaim of the legacy SharedPreferences blob — SurgeDnsStore moved
// from storage to cacheDir.
appContext.deleteSharedPreferences("amethyst_dns_cache")
dnsStore.load()
}
@@ -71,12 +71,6 @@ class SurgeDnsStore(
* call from a background thread.
*/
fun load() {
// One-shot reclaim of the legacy JSON blob — this class moved to a binary format. Done
// here (not in the constructor) so the syscall happens on the load() background thread
// instead of whatever thread builds the store.
val legacy = File(file.parentFile, LEGACY_FILE_NAME)
if (legacy.exists()) legacy.delete()
if (!file.exists()) return
val records =
try {
@@ -192,7 +186,6 @@ class SurgeDnsStore(
companion object {
private const val TAG = "SurgeDnsStore"
const val FILE_NAME = "dns_cache_v1.bin"
private const val LEGACY_FILE_NAME = "dns_cache_v1.json"
// 'SNSC' — Surge dNS Cache.
private const val MAGIC = 0x534E5343
@@ -155,19 +155,4 @@ class SurgeDnsStoreTest {
store.load() // must not throw
assertTrue(dns.snapshot().isEmpty())
}
@Test
fun `load deletes the legacy json sibling`() {
val legacy = File(tempFolder.root, "dns_cache_v1.json")
legacy.writeText("[]")
assertTrue(legacy.exists())
val target = File(tempFolder.root, "dns_cache_v1.bin")
val (store, _) = newStore(target)
// Construction must not touch the filesystem — only load() may.
assertTrue("constructor should not delete legacy file", legacy.exists())
store.load()
assertFalse("legacy json blob should be reclaimed by load()", legacy.exists())
}
}