/// <summary>
        /// (Thread Safe) Marks a chunk as recieved.
        /// </summary>
        private static void RegisterSuccessfulChunk(FlowMetaData chunkMeta)
        {
            lock (chunkDictionaryLock)
            {
                FileMetaData fileMeta;

                if (!uploadChunkDictionary.TryGetValue(chunkMeta.FlowIdentifier, out fileMeta))
                {
                    fileMeta = new FileMetaData(chunkMeta);
                    uploadChunkDictionary[chunkMeta.FlowIdentifier] = fileMeta;
                }

                fileMeta.RegisterChunkAsReceived(chunkMeta);
                if (fileMeta.IsComplete)
                {
                    uploadChunkDictionary.Remove(chunkMeta.FlowIdentifier);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// (Thread Safe) Marks a chunk as recieved.
        /// </summary>
        private static bool RegisterSuccessfulChunk(FlowMetaData chunkMeta)
        {
            FileMetaData fileMeta;
            lock (chunkCacheLock)
            {
                fileMeta = GetFileMetaData(chunkMeta.FlowIdentifier);

                if (fileMeta == null)
                {
                    fileMeta = new FileMetaData(chunkMeta);
                    uploadChunkCache.Add(chunkMeta.FlowIdentifier, fileMeta, DefaultCacheItemPolicy());
                }

                fileMeta.RegisterChunkAsReceived(chunkMeta);
                if (fileMeta.IsComplete)
                {
                    // Since we are using a cache and memory is automatically disposed,
                    // we don't need to do this, so we won't so we can keep a record of
                    // our completed uploads.
                    //uploadChunkCache.Remove(chunkMeta.FlowIdentifier);
                }
            }
            return fileMeta.IsComplete;
        }