Added button to create the remote folder, when using FTP. This closes #2. Added progressbars and status text to the status window. This closes #7. Fixed issues with interrupted uploads, if there were files, but the manifest was incomplete. The FTP connection now has keep-alive disabled. This closes #15. Fixed #12 for now, the fix could have more grace, but works for now. git-svn-id: https://duplicati.googlecode.com/svn/trunk@112 59da171f-624f-0410-aa54-27559c288bec
66 lines
1.7 KiB
C#
66 lines
1.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
namespace Duplicati.Library.Core
|
|
{
|
|
public class ProgressReportingStream : OverrideableStream
|
|
{
|
|
public delegate void ProgressDelegate(int progress);
|
|
public event ProgressDelegate Progress;
|
|
private int m_lastPg;
|
|
private long m_expectedSize;
|
|
private long m_streamOffset;
|
|
|
|
public ProgressReportingStream(System.IO.Stream basestream, long expectedSize)
|
|
: base(basestream)
|
|
{
|
|
m_lastPg = -1;
|
|
m_expectedSize = expectedSize;
|
|
m_streamOffset = 0;
|
|
}
|
|
|
|
public override int Read(byte[] buffer, int offset, int count)
|
|
{
|
|
ReportProgress();
|
|
|
|
int r = base.Read(buffer, offset, count);
|
|
m_streamOffset += r;
|
|
|
|
ReportProgress();
|
|
|
|
return r;
|
|
}
|
|
|
|
public override void Write(byte[] buffer, int offset, int count)
|
|
{
|
|
ReportProgress();
|
|
|
|
base.Write(buffer, offset, count);
|
|
m_streamOffset += count;
|
|
|
|
ReportProgress();
|
|
}
|
|
|
|
protected override void Dispose(bool disposing)
|
|
{
|
|
/*if (Progress != null)
|
|
Progress(100);*/
|
|
base.Dispose(disposing);
|
|
}
|
|
|
|
private void ReportProgress()
|
|
{
|
|
if (Progress != null)
|
|
{
|
|
int pg = (int)(((m_streamOffset) / (double)m_expectedSize) * 100);
|
|
if (pg != m_lastPg)
|
|
{
|
|
m_lastPg = pg;
|
|
Progress(pg);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|