Skip to content

Commit f83535e

Browse files
committed
fix: handle invalid pid file format
Closes #6
1 parent 1a79b0f commit f83535e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/flutter_single_instance.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,16 @@ abstract class FlutterSingleInstance {
109109

110110
final data = await pidFile.readAsString();
111111

112-
_instance = Instance.fromJson(jsonDecode(data));
112+
final json;
113+
114+
try {
115+
json = jsonDecode(data);
116+
} catch (e, s) {
117+
logger.finest("Pid file is wrong format, assuming first instance", e, s);
118+
return true;
119+
}
120+
121+
_instance = Instance.fromJson(json);
113122

114123
logger.finest("Pid file found, verifying instance: $_instance");
115124

0 commit comments

Comments
 (0)