Browse Source

fix weird logic for reading files.

tags/3.0
icylogic 8 years ago
parent
commit
3b7cbf8020
1 changed files with 4 additions and 16 deletions
  1. +4
    -16
      shadowsocks-csharp/Controller/Service/AvailabilityStatistics.cs

+ 4
- 16
shadowsocks-csharp/Controller/Service/AvailabilityStatistics.cs View File

@@ -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<Statistics>(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);
}
}



Loading…
Cancel
Save