pull/1/head
Ogoun 5 years ago
parent 80b9a490a3
commit 9efb30a07e

@ -178,7 +178,9 @@ namespace ZeroLevel.Services.FileSystem
}
}
if (Directory.Exists(targetFolder) == false)
{
Directory.CreateDirectory(targetFolder);
}
var tmpZip = Path.Combine(Configuration.BaseDirectory, "temp", Path.GetRandomFileName());
var tmp = Directory.CreateDirectory(tmpZip);
var zipFile = Path.Combine(tmp.FullName, "zip.zip");
@ -239,8 +241,9 @@ namespace ZeroLevel.Services.FileSystem
deleted = true;
}
}
catch
catch(Exception ex)
{
Log.SystemError(ex, $"[FSUtils.RemoveFolder] Fault remove folder {path}");
try_counter++;
Thread.Sleep(fault_timeout_period);
}

@ -0,0 +1,43 @@
using System;
using System.Diagnostics;
using System.Threading;
namespace ZeroLevel.Services.Utils
{
public sealed class Clock
: IDisposable
{
private readonly long _maxIdleTime = TimeSpan.FromSeconds(10).Ticks;
private const long TicksMultiplier = 1000 * TimeSpan.TicksPerMillisecond;
private readonly ThreadLocal<DateTime> _startTime =
new ThreadLocal<DateTime>(() => DateTime.UtcNow, false);
private readonly ThreadLocal<double> _startTimestamp =
new ThreadLocal<double>(() => Stopwatch.GetTimestamp(), false);
public DateTime UtcNow
{
get
{
double endTimestamp = Stopwatch.GetTimestamp();
var durationInTicks = (endTimestamp - _startTimestamp.Value) / Stopwatch.Frequency * TicksMultiplier;
if (durationInTicks >= _maxIdleTime)
{
_startTimestamp.Value = Stopwatch.GetTimestamp();
_startTime.Value = DateTime.UtcNow;
return _startTime.Value;
}
return _startTime.Value.AddTicks((long)durationInTicks);
}
}
public void Dispose()
{
_startTime.Dispose();
_startTimestamp.Dispose();
}
}
}
Loading…
Cancel
Save

Powered by TurnKey Linux.