|
|
@ -45,8 +45,6 @@ namespace ZeroLevel.Services.Network.FileTransfer
|
|
|
|
private readonly object _locker = new object();
|
|
|
|
private readonly object _locker = new object();
|
|
|
|
private long _cleanErrorsTaskId;
|
|
|
|
private long _cleanErrorsTaskId;
|
|
|
|
|
|
|
|
|
|
|
|
private readonly Dictionary<long, object> _incomingLocks = new Dictionary<long, object>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public FileReceiver(string path, string disk_prefix = "DRIVE_")
|
|
|
|
public FileReceiver(string path, string disk_prefix = "DRIVE_")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_disk_prefix = disk_prefix;
|
|
|
|
_disk_prefix = disk_prefix;
|
|
|
@ -69,7 +67,7 @@ namespace ZeroLevel.Services.Network.FileTransfer
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Incoming(FileStartFrame info, string clientFolderName)
|
|
|
|
public InvokeResult Incoming(FileStartFrame info, string clientFolderName)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -78,9 +76,6 @@ namespace ZeroLevel.Services.Network.FileTransfer
|
|
|
|
lock (_locker)
|
|
|
|
lock (_locker)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (false == _incoming.ContainsKey(info.UploadFileTaskId))
|
|
|
|
if (false == _incoming.ContainsKey(info.UploadFileTaskId))
|
|
|
|
{
|
|
|
|
|
|
|
|
_incomingLocks.Add(info.UploadFileTaskId, new object());
|
|
|
|
|
|
|
|
lock (_incomingLocks[info.UploadFileTaskId])
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string path = BuildFilePath(clientFolderName, info.FilePath);
|
|
|
|
string path = BuildFilePath(clientFolderName, info.FilePath);
|
|
|
|
_incoming.Add(info.UploadFileTaskId, new FileWriter(path));
|
|
|
|
_incoming.Add(info.UploadFileTaskId, new FileWriter(path));
|
|
|
@ -88,33 +83,34 @@ namespace ZeroLevel.Services.Network.FileTransfer
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Log.Error("[FileReceiver]", ex);
|
|
|
|
Log.Error("[FileReceiver]", ex);
|
|
|
|
|
|
|
|
return InvokeResult.Fault(ex.Message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return InvokeResult.Succeeding();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Incoming(FileFrame chunk)
|
|
|
|
public InvokeResult Incoming(FileFrame chunk)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
FileWriter stream;
|
|
|
|
FileWriter stream;
|
|
|
|
if (_incoming.TryGetValue(chunk.UploadFileTaskId, out stream))
|
|
|
|
if (_incoming.TryGetValue(chunk.UploadFileTaskId, out stream))
|
|
|
|
{
|
|
|
|
|
|
|
|
lock (_incomingLocks[chunk.UploadFileTaskId])
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
stream.Write(chunk.Offset, chunk.Payload);
|
|
|
|
stream.Write(chunk.Offset, chunk.Payload);
|
|
|
|
|
|
|
|
return InvokeResult.Succeeding();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return InvokeResult.Fault("File not expected.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Log.Error("[FileReceiver]", ex);
|
|
|
|
Log.Error("[FileReceiver]", ex);
|
|
|
|
|
|
|
|
return InvokeResult.Fault(ex.Message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Incoming(FileEndFrame info)
|
|
|
|
public InvokeResult Incoming(FileEndFrame info)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -126,7 +122,9 @@ namespace ZeroLevel.Services.Network.FileTransfer
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Log.Error("[FileReceiver]", ex);
|
|
|
|
Log.Error("[FileReceiver]", ex);
|
|
|
|
|
|
|
|
return InvokeResult.Fault(ex.Message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return InvokeResult.Succeeding();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Remove(long uploadTaskId)
|
|
|
|
private void Remove(long uploadTaskId)
|
|
|
|