2013-03-27 16:06:45 +01:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2013-03-08 22:24:54 +01:00
|
|
|
using System.Text;
|
2013-03-27 16:06:45 +01:00
|
|
|
using Duplicati.Library.Interface;
|
|
|
|
|
|
2013-05-08 20:17:07 +02:00
|
|
|
namespace Duplicati.Library.Main.Volumes
|
2013-03-27 16:06:45 +01:00
|
|
|
{
|
|
|
|
|
public class BlockVolumeWriter : VolumeWriterBase
|
|
|
|
|
{
|
|
|
|
|
private long m_blocks;
|
|
|
|
|
private long m_sourcesize;
|
|
|
|
|
|
|
|
|
|
public long Blocks { get { return m_blocks; } }
|
|
|
|
|
public long SourceSize { get { return m_sourcesize; } }
|
|
|
|
|
|
|
|
|
|
public override RemoteVolumeType FileType { get { return RemoteVolumeType.Blocks; } }
|
|
|
|
|
|
2013-05-06 09:58:19 +02:00
|
|
|
public BlockVolumeWriter(Options options)
|
2013-03-27 16:06:45 +01:00
|
|
|
: base(options)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-30 22:46:34 +02:00
|
|
|
public void AddBlock(string hash, byte[] data, int offset, int size, CompressionHint hint)
|
2013-03-27 16:06:45 +01:00
|
|
|
{
|
|
|
|
|
m_blocks++;
|
|
|
|
|
m_sourcesize += size;
|
|
|
|
|
|
|
|
|
|
//Filenames are encoded with "modified Base64 for URL" https://en.wikipedia.org/wiki/Base64#URL_applications,
|
2013-05-08 21:29:59 +02:00
|
|
|
using (var s = m_compression.CreateFile(Library.Utility.Utility.Base64PlainToBase64Url(hash), hint, DateTime.UtcNow))
|
2013-08-30 22:46:34 +02:00
|
|
|
s.Write(data, offset, size);
|
2013-03-27 16:06:45 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|