Exemplo n.º 1
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);
     }
 }
Exemplo n.º 2
0
        public void MarkChunkAsEmpty(int ChunkId, int FileId)
        {
            Logger.Debug($"M: MARK CHUNK {ChunkId} AS NOT WRITTEN BY {FileId}");
            Chunk Chunk = GetChunkByIdInternal(ChunkId);

            Chunk.SetNotWritten();
            if (!(Files.ContainsKey(FileId)))
            {
                throw new FileNotFoundException($"File {FileId} not found in Metadata");
            }
            Files[FileId].DeleteChunk(ChunkId);
            if (!(Chunk.IsWritten()))
            {
                if (WrittenChunks.ContainsKey(Chunk.Id))
                {
                    WrittenChunks.Remove(Chunk.Id);
                }
                try
                {
                    Chunk PreChunk = GetChunkBeforIfEmpty(Chunk);
                    Chunk = CombineChunks(PreChunk, Chunk);
                }
                catch (ChunkNotFoundException)
                {
                }
                try
                {
                    Chunk AfterChunk = GetChunkAfterIfEmpty(Chunk);
                    Chunk = CombineChunks(Chunk, AfterChunk);
                }
                catch (ChunkNotFoundException)
                {
                }
                if (!(EmptyChunks.ContainsKey(Chunk.Id)))
                {
                    EmptyChunks.Add(Chunk.Id, Chunk);
                    EmptyChunksStart.Add(Chunk.Start, Chunk);
                    EmptyChunksLength.Add(Chunk.Length, Chunk);
                }
            }
        }