Browse Source

create statistics file if not exists.

tags/3.0
Simon Dong 8 years ago
parent
commit
0b73017250
1 changed files with 14 additions and 3 deletions
  1. +14
    -3
      shadowsocks-csharp/Controller/Service/AvailabilityStatistics.cs

+ 14
- 3
shadowsocks-csharp/Controller/Service/AvailabilityStatistics.cs View File

@@ -258,9 +258,20 @@ namespace Shadowsocks.Controller
Logging.Debug($"loading statistics from {path}"); Logging.Debug($"loading statistics from {path}");
if (!File.Exists(path)) if (!File.Exists(path))
{ {
Console.WriteLine($"statistics file does not exist, try to reload {RetryInterval / 60 / 1000} minutes later");
_timer.Change(RetryInterval, Interval);
return;
try {
using (FileStream fs = File.Create(path))
{
//do nothing
}
}catch(Exception e)
{
Logging.LogUsefulException(e);
}
if (!File.Exists(path)) {
Console.WriteLine($"statistics file does not exist, try to reload {RetryInterval / 60 / 1000} minutes later");
_timer.Change(RetryInterval, Interval);
return;
}
} }
RawStatistics = (from l in File.ReadAllLines(path).Skip(1) RawStatistics = (from l in File.ReadAllLines(path).Skip(1)
let strings = l.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries) let strings = l.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries)


Loading…
Cancel
Save