From 3b7cbf8020f95bac267685fd5354b5ed029410fc Mon Sep 17 00:00:00 2001 From: icylogic Date: Mon, 29 Feb 2016 21:36:55 +0800 Subject: [PATCH] fix weird logic for reading files. --- .../Service/AvailabilityStatistics.cs | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/shadowsocks-csharp/Controller/Service/AvailabilityStatistics.cs b/shadowsocks-csharp/Controller/Service/AvailabilityStatistics.cs index c0467393..17f66f5c 100644 --- a/shadowsocks-csharp/Controller/Service/AvailabilityStatistics.cs +++ b/shadowsocks-csharp/Controller/Service/AvailabilityStatistics.cs @@ -260,23 +260,9 @@ namespace Shadowsocks.Controller Logging.Debug($"loading statistics from {path}"); if (!File.Exists(path)) { - try - { - using (File.Create(path)) - { - //do nothing - } - } - catch (Exception e) - { - Logging.LogUsefulException(e); - } - if (!File.Exists(path)) + using (File.Create(path)) { - Console.WriteLine( - $"statistics file does not exist, try to reload {_retryInterval.TotalMinutes} minutes later"); - _recorder.Change(_retryInterval, RecordingInterval); - return; + //do nothing } } RawStatistics = JsonConvert.DeserializeObject(File.ReadAllText(path)) ?? RawStatistics; @@ -284,6 +270,8 @@ namespace Shadowsocks.Controller catch (Exception e) { Logging.LogUsefulException(e); + Console.WriteLine($"failed to load statistics; try to reload {_retryInterval.TotalMinutes} minutes later"); + _recorder.Change(_retryInterval, RecordingInterval); } }