Skip to content

Commit

Permalink
Fix #52: When using split parity, The Data Space views need to accumu…
Browse files Browse the repository at this point in the history
…late 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
  • Loading branch information
Smurf-IV committed Jun 30, 2019
1 parent d09106b commit 9786ae0
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 135 deletions.
2 changes: 1 addition & 1 deletion Elucidate/Elucidate/Elucidate.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</AssemblyInfoVersionSettings>
<PrimaryVersionType>AssemblyVersionAttribute</PrimaryVersionType>
<AssemblyInfoFilePath>Properties\AssemblyInfo.cs</AssemblyInfoFilePath>
<AssemblyVersion>2019.6.986.30</AssemblyVersion>
<AssemblyVersion>2019.6.990.30</AssemblyVersion>
<UpdatePackageVersion>False</UpdatePackageVersion>
<AssemblyInfoVersionType>SettingsVersion</AssemblyInfoVersionType>
<InheritWinAppVersionFrom>None</InheritWinAppVersionFrom>
Expand Down
39 changes: 5 additions & 34 deletions Elucidate/Elucidate/Forms/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -559,34 +559,6 @@ private void DriveGridOnCellEndEdit(object sender, DataGridViewCellEventArgs e)

#endregion snapShotSourcesTreeView

public List<CoveragePath> GetPathsOfInterest()
{
List<CoveragePath> pathsOfInterest = new List<CoveragePath>();

// Snap-Shot source might be root or folders, so we handle both cases
foreach (DataGridViewRow row in snapShotSources.driveGrid.Rows)
{
if (row.Tag is CoveragePath coveragePath)
{
pathsOfInterest.Add(coveragePath);
}
}

if (!string.IsNullOrEmpty(parityLocation1.Text)) { pathsOfInterest.Add(new CoveragePath { FullPath = Path.GetFullPath(parityLocation1.Text), PathType = PathTypeEnum.Parity }); }

if (!string.IsNullOrEmpty(parityLocation2.Text)) { pathsOfInterest.Add(new CoveragePath { FullPath = Path.GetFullPath(parityLocation2.Text), PathType = PathTypeEnum.Parity }); }

if (!string.IsNullOrEmpty(parityLocation3.Text)) { pathsOfInterest.Add(new CoveragePath { FullPath = Path.GetFullPath(parityLocation3.Text), PathType = PathTypeEnum.Parity }); }

if (!string.IsNullOrEmpty(parityLocation4.Text)) { pathsOfInterest.Add(new CoveragePath { FullPath = Path.GetFullPath(parityLocation4.Text), PathType = PathTypeEnum.Parity }); }

if (!string.IsNullOrEmpty(parityLocation5.Text)) { pathsOfInterest.Add(new CoveragePath { FullPath = Path.GetFullPath(parityLocation5.Text), PathType = PathTypeEnum.Parity }); }

if (!string.IsNullOrEmpty(parityLocation6.Text)) { pathsOfInterest.Add(new CoveragePath { FullPath = Path.GetFullPath(parityLocation6.Text), PathType = PathTypeEnum.Parity }); }

return pathsOfInterest;
}

private bool ValidateFormData()
{
errorProvider1.Clear();
Expand Down Expand Up @@ -832,13 +804,12 @@ private void btnSave_Click(object sender, EventArgs e)
AutoSaveGB = (uint)numAutoSaveGB.Value
};

foreach (DataGridViewRow row in exludedFilesView.Rows)
foreach (string value in exludedFilesView.Rows.Cast<DataGridViewRow>()
.Select(row => $"{row.Cells[0].Value}")
.Where(value => !string.IsNullOrWhiteSpace(value))
)
{
string value = $"{row.Cells[0].Value}";
if (!string.IsNullOrWhiteSpace(value))
{
cfgToSave.ExcludePatterns.Add(value);
}
cfgToSave.ExcludePatterns.Add(value);
}

foreach (DataGridViewRow row in snapShotSources.driveGrid.Rows)
Expand Down
158 changes: 62 additions & 96 deletions Elucidate/Elucidate/HelperClasses/ConfigFileHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -564,79 +564,32 @@ public List<CoveragePath> GetPathsOfInterest()
});
}

if (!string.IsNullOrWhiteSpace(ParityFile1))
{
pathsOfInterest.Add(new CoveragePath
{
FullPath = Path.GetFullPath(ParityFile1),
PathType = PathTypeEnum.Parity,
Name = @"Parity1"
});
}
AddParityCoverage(pathsOfInterest, ParityFile1, @"Parity1");

if (!string.IsNullOrWhiteSpace(ParityFile2))
{
pathsOfInterest.Add(new CoveragePath
{
FullPath = Path.GetFullPath(ParityFile2),
PathType = PathTypeEnum.Parity,
Name = @"Parity2"
});
}
AddParityCoverage(pathsOfInterest, ParityFile2, @"Parity2");

if (!string.IsNullOrWhiteSpace(ZParityFile))
{
pathsOfInterest.Add(new CoveragePath
{
FullPath = Path.GetFullPath(ZParityFile),
PathType = PathTypeEnum.Parity,
Name = @"ZParity"
});
}
AddParityCoverage(pathsOfInterest, ZParityFile, @"ZParity");

if (!string.IsNullOrWhiteSpace(ParityFile3))
{
pathsOfInterest.Add(new CoveragePath
{
FullPath = Path.GetFullPath(ParityFile3),
PathType = PathTypeEnum.Parity,
Name = @"Parity3"
});
}
AddParityCoverage(pathsOfInterest, ParityFile3, @"Parity3");

if (!string.IsNullOrWhiteSpace(ParityFile4))
{
pathsOfInterest.Add(new CoveragePath
{
FullPath = Path.GetFullPath(ParityFile4),
PathType = PathTypeEnum.Parity,
Name = @"Parity4"
});
}

if (!string.IsNullOrWhiteSpace(ParityFile5))
{
pathsOfInterest.Add(new CoveragePath
{
FullPath = Path.GetFullPath(ParityFile5),
PathType = PathTypeEnum.Parity,
Name = @"Parity5"
});
}

if (!string.IsNullOrWhiteSpace(ParityFile6))
{
pathsOfInterest.Add(new CoveragePath
{
FullPath = Path.GetFullPath(ParityFile6),
PathType = PathTypeEnum.Parity,
Name = @"Parity6"
});
}
AddParityCoverage(pathsOfInterest, ParityFile4, @"Parity4");

AddParityCoverage(pathsOfInterest, ParityFile5, @"Parity5");

AddParityCoverage(pathsOfInterest, ParityFile6, @"Parity6");

return pathsOfInterest;
}

private static void AddParityCoverage(List<CoveragePath> pathsOfInterest, string parityPaths, string parityName)
{
if (!string.IsNullOrWhiteSpace(parityPaths))
{
string[] parities = parityPaths.Trim().Split(",".ToCharArray());
pathsOfInterest.AddRange(parities.Select(parity => new CoveragePath { FullPath = Path.GetFullPath(parity), PathType = PathTypeEnum.Parity, Name = parityName }));
}
}

/// <summary>
/// Writes the config file
/// </summary>
Expand All @@ -651,40 +604,17 @@ public string Write(string trgtFileName)

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

// X-parity
// #-parity
fileContents.Append(Section3);

if (!string.IsNullOrEmpty(ParityFile2))
{
fileContents.AppendLine($"2-parity {(Directory.Exists(ParityFile2) ? Path.Combine(ParityFile2, @"snapraid.2.parity") : ParityFile2)}");
}

if (!string.IsNullOrEmpty(ZParityFile))
{
fileContents.AppendLine($"z-parity {(Directory.Exists(ZParityFile) ? Path.Combine(ZParityFile, @"snapraid.Z.parity") : ZParityFile)}");
}

if (!string.IsNullOrEmpty(ParityFile3))
{
fileContents.AppendLine($"3-parity {(Directory.Exists(ParityFile3) ? Path.Combine(ParityFile3, @"snapraid.3.parity") : ParityFile3)}");
}

if (!string.IsNullOrEmpty(ParityFile4))
{
fileContents.AppendLine($"4-parity {(Directory.Exists(ParityFile4) ? Path.Combine(ParityFile4, @"snapraid.4.parity") : ParityFile4)}");
}

if (!string.IsNullOrEmpty(ParityFile5))
{
fileContents.AppendLine($"5-parity {(Directory.Exists(ParityFile5) ? Path.Combine(ParityFile5, @"snapraid.5.parity") : ParityFile5)}");
}

if (!string.IsNullOrEmpty(ParityFile6))
{
fileContents.AppendLine($"6-parity {(Directory.Exists(ParityFile6) ? Path.Combine(ParityFile6, @"snapraid.6.parity") : ParityFile6)}");
}
AddParityToConfig(fileContents, ParityFile2, '2');
AddParityToConfig(fileContents, ZParityFile, 'z');
AddParityToConfig(fileContents, ParityFile3, '3');
AddParityToConfig(fileContents, ParityFile4, '4');
AddParityToConfig(fileContents, ParityFile5, '5');
AddParityToConfig(fileContents, ParityFile6, '6');

// content
fileContents.Append(Section4);
Expand Down Expand Up @@ -745,6 +675,42 @@ public string Write(string trgtFileName)
return string.Empty;
}

private static void AddParityToConfig(StringBuilder fileContents, string parityPaths, char offset)
{
if (!string.IsNullOrEmpty(parityPaths))
{
if (offset != char.MinValue)
{
fileContents.Append(offset).Append('-');
}

fileContents.Append("parity ");
string[] parities = parityPaths.Trim().Split(",".ToCharArray());
bool doneFirst = false;
foreach (string parity in parities)
{
if (doneFirst)
{
fileContents.Append(',');
}

fileContents.Append(parity);
doneFirst = true;
if (Directory.Exists(parity))
{
fileContents.Append(@"\snapraid");
if (offset != char.MinValue)
{
fileContents.Append('-').Append(offset);
}
fileContents.Append(@".parity");
}
}

fileContents.AppendLine();
}
}

private static StringBuilder Section1
{
get
Expand Down
4 changes: 2 additions & 2 deletions Elucidate/Elucidate/HelperClasses/StorageUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ public static List<ulong> GetDriveSizes(List<string> sources)
{
try
{
string pathRoot = GetPathRoot(source);
deviceSizes.Add(GetDriveSize(pathRoot));
string[] possiblePaths = source.Trim().Split(",".ToCharArray());
deviceSizes.Add(possiblePaths.Select(GetPathRoot).Sum(GetDriveSize));
}
catch (Exception ex)
{
Expand Down
4 changes: 2 additions & 2 deletions Elucidate/Elucidate/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@
// Build Number - Increment
// Revision - Day
//
[assembly: AssemblyVersion("2019.6.986.30")]
[assembly: AssemblyFileVersion("19.6.986.30")]
[assembly: AssemblyVersion("2019.6.990.30")]
[assembly: AssemblyFileVersion("19.6.990.30")]
[assembly: NeutralResourcesLanguage("en-US")]
// TODO: Add more relevant hints here
[assembly: Dependency("System", LoadHint.Always)]
Expand Down

0 comments on commit 9786ae0

Please sign in to comment.