Skip to content

Commit 22eb2c8

Browse files
committed
Call setupDirs before writeResolv in gateway init and start (#40)
On a normal app launch (setup already complete), setupDirs was never called. If Android cleared the files directory after an upgrade, the config/ directory was missing when writeResolv ran. Now both init() and start() call setupDirs() first, matching the bootstrap flow. The Kotlin-side writeResolvConf() also calls setupDirectories() internally as a safety net. Co-Authored-By: Mithun Gowda B <mithungowda.b7411@gmail.com>
1 parent 1f75891 commit 22eb2c8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

flutter_app/lib/services/gateway_service.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ class GatewayService {
4141

4242
final alreadyRunning = await NativeBridge.isGatewayRunning();
4343
if (alreadyRunning) {
44-
// Refresh resolv.conf so DNS keeps working even if the file was
45-
// deleted or corrupted while the app was in the background.
44+
// Ensure directories exist — Android may have cleared them after
45+
// an upgrade or while the app was in the background (#40).
46+
try { await NativeBridge.setupDirs(); } catch (_) {}
47+
// Refresh resolv.conf so DNS keeps working.
4648
await NativeBridge.writeResolv();
4749
// Write allowCommands config so the next gateway restart picks it up,
4850
// and in case the running gateway supports config hot-reload.
@@ -137,6 +139,8 @@ fs.writeFileSync(p, JSON.stringify(c, null, 2));
137139
));
138140

139141
try {
142+
// Ensure directories exist — Android may have cleared them (#40).
143+
await NativeBridge.setupDirs();
140144
// Refresh resolv.conf before every start so DNS always works.
141145
await NativeBridge.writeResolv();
142146
await _writeNodeAllowConfig();

0 commit comments

Comments
 (0)