Skip to content

Commit 9786ae0

Browse files
committed
Fix #52: When using split parity, The Data Space views need to accumulate individual areas
- Make sure Parity file names reflect the offsets - Make sure that individual Parity locations are added Fix #51: When using split parity, Warning is displayed about Data being larger than Parity size - Take into account aggregated parity areas for drives size check
1 parent d09106b commit 9786ae0

5 files changed

Lines changed: 72 additions & 135 deletions

File tree

Elucidate/Elucidate/Elucidate.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
</AssemblyInfoVersionSettings>
3131
<PrimaryVersionType>AssemblyVersionAttribute</PrimaryVersionType>
3232
<AssemblyInfoFilePath>Properties\AssemblyInfo.cs</AssemblyInfoFilePath>
33-
<AssemblyVersion>2019.6.986.30</AssemblyVersion>
33+
<AssemblyVersion>2019.6.990.30</AssemblyVersion>
3434
<UpdatePackageVersion>False</UpdatePackageVersion>
3535
<AssemblyInfoVersionType>SettingsVersion</AssemblyInfoVersionType>
3636
<InheritWinAppVersionFrom>None</InheritWinAppVersionFrom>

Elucidate/Elucidate/Forms/Settings.cs

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -559,34 +559,6 @@ private void DriveGridOnCellEndEdit(object sender, DataGridViewCellEventArgs e)
559559

560560
#endregion snapShotSourcesTreeView
561561

562-
public List<CoveragePath> GetPathsOfInterest()
563-
{
564-
List<CoveragePath> pathsOfInterest = new List<CoveragePath>();
565-
566-
// Snap-Shot source might be root or folders, so we handle both cases
567-
foreach (DataGridViewRow row in snapShotSources.driveGrid.Rows)
568-
{
569-
if (row.Tag is CoveragePath coveragePath)
570-
{
571-
pathsOfInterest.Add(coveragePath);
572-
}
573-
}
574-
575-
if (!string.IsNullOrEmpty(parityLocation1.Text)) { pathsOfInterest.Add(new CoveragePath { FullPath = Path.GetFullPath(parityLocation1.Text), PathType = PathTypeEnum.Parity }); }
576-
577-
if (!string.IsNullOrEmpty(parityLocation2.Text)) { pathsOfInterest.Add(new CoveragePath { FullPath = Path.GetFullPath(parityLocation2.Text), PathType = PathTypeEnum.Parity }); }
578-
579-
if (!string.IsNullOrEmpty(parityLocation3.Text)) { pathsOfInterest.Add(new CoveragePath { FullPath = Path.GetFullPath(parityLocation3.Text), PathType = PathTypeEnum.Parity }); }
580-
581-
if (!string.IsNullOrEmpty(parityLocation4.Text)) { pathsOfInterest.Add(new CoveragePath { FullPath = Path.GetFullPath(parityLocation4.Text), PathType = PathTypeEnum.Parity }); }
582-
583-
if (!string.IsNullOrEmpty(parityLocation5.Text)) { pathsOfInterest.Add(new CoveragePath { FullPath = Path.GetFullPath(parityLocation5.Text), PathType = PathTypeEnum.Parity }); }
584-
585-
if (!string.IsNullOrEmpty(parityLocation6.Text)) { pathsOfInterest.Add(new CoveragePath { FullPath = Path.GetFullPath(parityLocation6.Text), PathType = PathTypeEnum.Parity }); }
586-
587-
return pathsOfInterest;
588-
}
589-
590562
private bool ValidateFormData()
591563
{
592564
errorProvider1.Clear();
@@ -832,13 +804,12 @@ private void btnSave_Click(object sender, EventArgs e)
832804
AutoSaveGB = (uint)numAutoSaveGB.Value
833805
};
834806

835-
foreach (DataGridViewRow row in exludedFilesView.Rows)
807+
foreach (string value in exludedFilesView.Rows.Cast<DataGridViewRow>()
808+
.Select(row => $"{row.Cells[0].Value}")
809+
.Where(value => !string.IsNullOrWhiteSpace(value))
810+
)
836811
{
837-
string value = $"{row.Cells[0].Value}";
838-
if (!string.IsNullOrWhiteSpace(value))
839-
{
840-
cfgToSave.ExcludePatterns.Add(value);
841-
}
812+
cfgToSave.ExcludePatterns.Add(value);
842813
}
843814

844815
foreach (DataGridViewRow row in snapShotSources.driveGrid.Rows)

Elucidate/Elucidate/HelperClasses/ConfigFileHelper.cs

Lines changed: 62 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -564,79 +564,32 @@ public List<CoveragePath> GetPathsOfInterest()
564564
});
565565
}
566566

567-
if (!string.IsNullOrWhiteSpace(ParityFile1))
568-
{
569-
pathsOfInterest.Add(new CoveragePath
570-
{
571-
FullPath = Path.GetFullPath(ParityFile1),
572-
PathType = PathTypeEnum.Parity,
573-
Name = @"Parity1"
574-
});
575-
}
567+
AddParityCoverage(pathsOfInterest, ParityFile1, @"Parity1");
576568

577-
if (!string.IsNullOrWhiteSpace(ParityFile2))
578-
{
579-
pathsOfInterest.Add(new CoveragePath
580-
{
581-
FullPath = Path.GetFullPath(ParityFile2),
582-
PathType = PathTypeEnum.Parity,
583-
Name = @"Parity2"
584-
});
585-
}
569+
AddParityCoverage(pathsOfInterest, ParityFile2, @"Parity2");
586570

587-
if (!string.IsNullOrWhiteSpace(ZParityFile))
588-
{
589-
pathsOfInterest.Add(new CoveragePath
590-
{
591-
FullPath = Path.GetFullPath(ZParityFile),
592-
PathType = PathTypeEnum.Parity,
593-
Name = @"ZParity"
594-
});
595-
}
571+
AddParityCoverage(pathsOfInterest, ZParityFile, @"ZParity");
596572

597-
if (!string.IsNullOrWhiteSpace(ParityFile3))
598-
{
599-
pathsOfInterest.Add(new CoveragePath
600-
{
601-
FullPath = Path.GetFullPath(ParityFile3),
602-
PathType = PathTypeEnum.Parity,
603-
Name = @"Parity3"
604-
});
605-
}
573+
AddParityCoverage(pathsOfInterest, ParityFile3, @"Parity3");
606574

607-
if (!string.IsNullOrWhiteSpace(ParityFile4))
608-
{
609-
pathsOfInterest.Add(new CoveragePath
610-
{
611-
FullPath = Path.GetFullPath(ParityFile4),
612-
PathType = PathTypeEnum.Parity,
613-
Name = @"Parity4"
614-
});
615-
}
616-
617-
if (!string.IsNullOrWhiteSpace(ParityFile5))
618-
{
619-
pathsOfInterest.Add(new CoveragePath
620-
{
621-
FullPath = Path.GetFullPath(ParityFile5),
622-
PathType = PathTypeEnum.Parity,
623-
Name = @"Parity5"
624-
});
625-
}
626-
627-
if (!string.IsNullOrWhiteSpace(ParityFile6))
628-
{
629-
pathsOfInterest.Add(new CoveragePath
630-
{
631-
FullPath = Path.GetFullPath(ParityFile6),
632-
PathType = PathTypeEnum.Parity,
633-
Name = @"Parity6"
634-
});
635-
}
575+
AddParityCoverage(pathsOfInterest, ParityFile4, @"Parity4");
576+
577+
AddParityCoverage(pathsOfInterest, ParityFile5, @"Parity5");
578+
579+
AddParityCoverage(pathsOfInterest, ParityFile6, @"Parity6");
636580

637581
return pathsOfInterest;
638582
}
639583

584+
private static void AddParityCoverage(List<CoveragePath> pathsOfInterest, string parityPaths, string parityName)
585+
{
586+
if (!string.IsNullOrWhiteSpace(parityPaths))
587+
{
588+
string[] parities = parityPaths.Trim().Split(",".ToCharArray());
589+
pathsOfInterest.AddRange(parities.Select(parity => new CoveragePath { FullPath = Path.GetFullPath(parity), PathType = PathTypeEnum.Parity, Name = parityName }));
590+
}
591+
}
592+
640593
/// <summary>
641594
/// Writes the config file
642595
/// </summary>
@@ -651,40 +604,17 @@ public string Write(string trgtFileName)
651604

652605
// parity
653606
fileContents.Append(Section2);
654-
fileContents.AppendLine($"parity {(Directory.Exists(ParityFile1) ? Path.Combine(ParityFile1, @"snapraid.1.parity") : ParityFile1)}");
607+
AddParityToConfig(fileContents, ParityFile1, char.MinValue);
655608

656-
// X-parity
609+
// #-parity
657610
fileContents.Append(Section3);
658611

659-
if (!string.IsNullOrEmpty(ParityFile2))
660-
{
661-
fileContents.AppendLine($"2-parity {(Directory.Exists(ParityFile2) ? Path.Combine(ParityFile2, @"snapraid.2.parity") : ParityFile2)}");
662-
}
663-
664-
if (!string.IsNullOrEmpty(ZParityFile))
665-
{
666-
fileContents.AppendLine($"z-parity {(Directory.Exists(ZParityFile) ? Path.Combine(ZParityFile, @"snapraid.Z.parity") : ZParityFile)}");
667-
}
668-
669-
if (!string.IsNullOrEmpty(ParityFile3))
670-
{
671-
fileContents.AppendLine($"3-parity {(Directory.Exists(ParityFile3) ? Path.Combine(ParityFile3, @"snapraid.3.parity") : ParityFile3)}");
672-
}
673-
674-
if (!string.IsNullOrEmpty(ParityFile4))
675-
{
676-
fileContents.AppendLine($"4-parity {(Directory.Exists(ParityFile4) ? Path.Combine(ParityFile4, @"snapraid.4.parity") : ParityFile4)}");
677-
}
678-
679-
if (!string.IsNullOrEmpty(ParityFile5))
680-
{
681-
fileContents.AppendLine($"5-parity {(Directory.Exists(ParityFile5) ? Path.Combine(ParityFile5, @"snapraid.5.parity") : ParityFile5)}");
682-
}
683-
684-
if (!string.IsNullOrEmpty(ParityFile6))
685-
{
686-
fileContents.AppendLine($"6-parity {(Directory.Exists(ParityFile6) ? Path.Combine(ParityFile6, @"snapraid.6.parity") : ParityFile6)}");
687-
}
612+
AddParityToConfig(fileContents, ParityFile2, '2');
613+
AddParityToConfig(fileContents, ZParityFile, 'z');
614+
AddParityToConfig(fileContents, ParityFile3, '3');
615+
AddParityToConfig(fileContents, ParityFile4, '4');
616+
AddParityToConfig(fileContents, ParityFile5, '5');
617+
AddParityToConfig(fileContents, ParityFile6, '6');
688618

689619
// content
690620
fileContents.Append(Section4);
@@ -745,6 +675,42 @@ public string Write(string trgtFileName)
745675
return string.Empty;
746676
}
747677

678+
private static void AddParityToConfig(StringBuilder fileContents, string parityPaths, char offset)
679+
{
680+
if (!string.IsNullOrEmpty(parityPaths))
681+
{
682+
if (offset != char.MinValue)
683+
{
684+
fileContents.Append(offset).Append('-');
685+
}
686+
687+
fileContents.Append("parity ");
688+
string[] parities = parityPaths.Trim().Split(",".ToCharArray());
689+
bool doneFirst = false;
690+
foreach (string parity in parities)
691+
{
692+
if (doneFirst)
693+
{
694+
fileContents.Append(',');
695+
}
696+
697+
fileContents.Append(parity);
698+
doneFirst = true;
699+
if (Directory.Exists(parity))
700+
{
701+
fileContents.Append(@"\snapraid");
702+
if (offset != char.MinValue)
703+
{
704+
fileContents.Append('-').Append(offset);
705+
}
706+
fileContents.Append(@".parity");
707+
}
708+
}
709+
710+
fileContents.AppendLine();
711+
}
712+
}
713+
748714
private static StringBuilder Section1
749715
{
750716
get

Elucidate/Elucidate/HelperClasses/StorageUtil.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ public static List<ulong> GetDriveSizes(List<string> sources)
119119
{
120120
try
121121
{
122-
string pathRoot = GetPathRoot(source);
123-
deviceSizes.Add(GetDriveSize(pathRoot));
122+
string[] possiblePaths = source.Trim().Split(",".ToCharArray());
123+
deviceSizes.Add(possiblePaths.Select(GetPathRoot).Sum(GetDriveSize));
124124
}
125125
catch (Exception ex)
126126
{

Elucidate/Elucidate/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@
5858
// Build Number - Increment
5959
// Revision - Day
6060
//
61-
[assembly: AssemblyVersion("2019.6.986.30")]
62-
[assembly: AssemblyFileVersion("19.6.986.30")]
61+
[assembly: AssemblyVersion("2019.6.990.30")]
62+
[assembly: AssemblyFileVersion("19.6.990.30")]
6363
[assembly: NeutralResourcesLanguage("en-US")]
6464
// TODO: Add more relevant hints here
6565
[assembly: Dependency("System", LoadHint.Always)]

0 commit comments

Comments
 (0)