예제 #1
0
        private void AssembleFile(int FileId)
        {
            var    segments = queue.Where(q => q.FileID == FileId).OrderBy(q => q.Number);
            string filename = segments.First().Filename;
            bool   broken   = segments.Any(s => s.Status == JobStatus.Failed);

            if (broken)
            {
                filename = filename.ToUpper();
            }

            string path = Path.Combine(CompletedDirectory.FullName, filename);

            using (FileStream file = File.Open(path, FileMode.Create, FileAccess.Write, FileShare.None)) {
                foreach (var segment in segments)
                {
                    if (segment.Status == JobStatus.Complete)
                    {
                        using (FileStream part = new FileStream(segment.CacheLocation, FileMode.Open, FileAccess.Read, FileShare.None)) {
                            if (segment.ByteOffset > -1)
                            {
                                file.Position = segment.ByteOffset;
                            }
                            part.CopyTo(file);
                        }
                        File.Delete(segment.CacheLocation);
                    }
                }
            }

            assembled[FileId] = true;
            FileCompleted(this, new FileCompletedEventArgs(path, broken));
            if (assembled.All(f => f.Value))
            {
                CacheDirectory.Delete(true);
                QueueCompleted(this, System.EventArgs.Empty);
            }
        }
예제 #2
0
 public void ClearCache()
 {
     CacheDirectory.Delete(true);
     CacheDirectory.Create();
 }
예제 #3
0
 public void ClearCache()
 {
     CacheDirectory.Delete(true);
     InitChildDirectory(CACHE_DIR);
 }
예제 #4
0
파일: Cache.cs 프로젝트: NightEule5/Sigma
 public void Clear() => CacheDirectory.Delete(true);