private List <HFile> GetFiles(SnapshotLocation snapshotLocation) { BlackList blackList = GetBlackList(snapshotLocation); IEnumerable <HFile> files = snapshotRepository.EnumerateFiles(snapshotLocation, blackList); return(files.ToList()); }
public void PotNameAndSnapshotDateAndPath() { SnapshotLocation snapshotLocation = new SnapshotLocation("pot1~2020-05-12 12:34:00>asd/qwe"); Assert.That(snapshotLocation.PotName, Is.EqualTo("pot1"), () => "Pot name is not correct."); Assert.That(snapshotLocation.SnapshotDate, Is.EqualTo(new DateTime(2020, 05, 12, 12, 34, 00)), () => "Snapshot date is not correct."); Assert.That(snapshotLocation.SnapshotIndex, Is.Null, () => "Snapshot index is not correct."); Assert.That(snapshotLocation.InternalPath, Is.EqualTo("asd/qwe"), () => "Internal path is not correct."); }
public void PotNameAndSnapshotIndex5AndPath() { SnapshotLocation snapshotLocation = new SnapshotLocation("pot1~5>asd/qwe"); Assert.That(snapshotLocation.PotName, Is.EqualTo("pot1"), () => "Pot name is not correct."); Assert.That(snapshotLocation.SnapshotDate, Is.Null, () => "Snapshot date is not correct."); Assert.That(snapshotLocation.SnapshotIndex, Is.EqualTo(5), () => "Snapshot index is not correct."); Assert.That(snapshotLocation.InternalPath, Is.EqualTo("asd/qwe"), () => "Internal path is not correct."); }
public void OnlyPotNameIsSpecified() { SnapshotLocation snapshotLocation = new SnapshotLocation("pot1"); Assert.That(snapshotLocation.PotName, Is.EqualTo("pot1"), () => "Pot name is not correct."); Assert.That(snapshotLocation.SnapshotDate, Is.Null, () => "Snapshot date is not correct."); Assert.That(snapshotLocation.SnapshotIndex, Is.Null, () => "Snapshot index is not correct."); Assert.That(snapshotLocation.InternalPath, Is.Null, () => "Internal path is not correct."); }
private BlackList GetBlackList(SnapshotLocation snapshotLocation) { if (snapshotLocation.PotName == null) { return(null); } DiskPathCollection blackListPaths = blackListRepository.Get(snapshotLocation.PotName); return(new BlackList(blackListPaths)); }
public async Task Execute(Arguments arguments) { CreateSnapshotRequest request = new() { PotName = PotName }; IDiskAnalysisProgress diskAnalysisProgress = await requestBus.PlaceRequest <CreateSnapshotRequest, IDiskAnalysisProgress>(request); diskAnalysisProgress.Progress += HandleAnalysisProgress; diskAnalysisProgress.WaitToEnd(); SnapshotLocation = "missing"; }
public Snapshot RetrieveSnapshot(SnapshotLocation location) { if (string.IsNullOrEmpty(location.PotName)) { throw new Exception("Pot name was not provided."); } if (location.SnapshotIndex.HasValue) { return(snapshotRepository.GetByIndex(location.PotName, location.SnapshotIndex.Value)); } if (location.SnapshotDate.HasValue) { DateTime searchedDate = location.SnapshotDate.Value; Snapshot snapshot = snapshotRepository.GetByExactDateTime(location.PotName, searchedDate); if (snapshot == null && searchedDate.TimeOfDay == TimeSpan.Zero) { List <Snapshot> snapshots = snapshotRepository.GetByDate(location.PotName, searchedDate) .ToList(); if (snapshots.Count == 1) { snapshot = snapshots[0]; } else if (snapshots.Count > 1) { throw new Exception($"There are multiple snapshots that match the specified date. Pot = {location.PotName}; Date = {searchedDate}"); } } return(snapshot); } return(snapshotRepository.GetLast(location.PotName)); }
private static Snapshot GetSnapshot(this ISnapshotRepository snapshotRepository, SnapshotLocation snapshotLocation) { if (string.IsNullOrEmpty(snapshotLocation.PotName)) { return(null); } if (snapshotLocation.SnapshotIndex.HasValue) { return(snapshotRepository.GetByIndex(snapshotLocation.PotName, snapshotLocation.SnapshotIndex.Value)); } if (!snapshotLocation.SnapshotDate.HasValue) { return(snapshotRepository.GetLast(snapshotLocation.PotName)); } DateTime searchedDate = snapshotLocation.SnapshotDate.Value; Snapshot snapshot = snapshotRepository.GetByExactDateTime(snapshotLocation.PotName, searchedDate); if (snapshot == null && searchedDate.TimeOfDay == TimeSpan.Zero) { List <Snapshot> snapshots = snapshotRepository.GetByDate(snapshotLocation.PotName, searchedDate) .ToList(); if (snapshots.Count == 1) { snapshot = snapshots[0]; } else if (snapshots.Count > 1) { throw new Exception($"There are multiple snapshots that match the specified date. Pot = {snapshotLocation.PotName}; Date = {searchedDate}"); } } return(snapshot); }
public static IEnumerable <HFile> EnumerateFiles(this ISnapshotRepository snapshotRepository, SnapshotLocation snapshotLocation, BlackList blackList = null) { Snapshot snapshot = snapshotRepository.GetSnapshot(snapshotLocation); return(snapshot == null ? Enumerable.Empty <HFile>() : snapshot.EnumerateFiles(snapshotLocation.InternalPath, blackList)); }