Ejemplo n.º 1
0
        protected override void CryptChunk(MegaChunk chunk)
        {
            var data = chunk.Data;
            var hndl = chunk.Handle;
            chunk.Mac = Crypto.DecryptCtr(chunk.Handle.AesAlg, data, chunk.Handle.Nonce, chunk.Offset);
            lock(streamLock)
            {
                hndl.Stream.Seek(chunk.Offset, SeekOrigin.Begin);
                hndl.Stream.Write(data, 0, chunk.Size);
            }
            hndl.chunksProcessed++;
            chunk.ClearData();

            if (chunk.Handle.chunksProcessed == chunk.Handle.Chunks.Count)
            {
                Util.StartThread(() =>
                {
                    FinishFile((DownloadHandle)chunk.Handle);
                }, "transfer_finish_file");
            }
        }
Ejemplo n.º 2
0
        private void OnUploadedChunk(MegaChunk chunk, UploadDataCompletedEventArgs e)
        {
            chunk.ClearData();

            chunk.Handle.chunksProcessed++;
            if (chunk.Handle.chunksProcessed == chunk.Handle.Chunks.Count)
            {
                Util.StartThread(() =>
                {
                    var uploadHandle = Encoding.UTF8.GetString(e.Result);
                    FinishFile((UploadHandle)chunk.Handle, uploadHandle);
                }, "transfer_finish_file");
            }
        }