コード例 #1
0
        public void WriteChunk(int ChunkId, int FileId)
        {
            Logger.Debug($"M: MARK CHUNK {ChunkId} AS WRITTEN BY {FileId}");
            Chunk Chunk = GetChunkByIdInternal(ChunkId);

            Chunk.SetWritten();
            if (EmptyChunks.ContainsKey(Chunk.Id))
            {
                EmptyChunks.Remove(Chunk.Id);
            }
            if (EmptyChunksStart.ContainsKey(Chunk.Start))
            {
                EmptyChunksStart.Remove(Chunk.Start);
            }
            if (EmptyChunksLength.ContainsKey(Chunk.Length))
            {
                EmptyChunksLength.Remove(Chunk.Length);
            }
            if (!(WrittenChunks.ContainsKey(Chunk.Id)))
            {
                WrittenChunks.Add(Chunk.Id, Chunk);
            }
            if (!(FileId == 0))
            {
                if (!(Files.ContainsKey(FileId)))
                {
                    throw new FileNotFoundException($"File {FileId} not found in Metadata");
                }
                Files[FileId].AddChunk(ChunkId);
            }
        }
コード例 #2
0
 private void RemoveChunk(Chunk Chunk)
 {
     if (WrittenChunks.ContainsKey(Chunk.Id))
     {
         WrittenChunks.Remove(Chunk.Id);
     }
     if (EmptyChunks.ContainsKey(Chunk.Id))
     {
         EmptyChunks.Remove(Chunk.Id);
     }
     if (EmptyChunksStart.ContainsKey(Chunk.Start))
     {
         EmptyChunksStart.Remove(Chunk.Start);
     }
     if (EmptyChunksLength.ContainsKey(Chunk.Length))
     {
         EmptyChunksLength.Remove(Chunk.Length);
     }
 }