Skip to content

Commit

Permalink
add crc32 hashing for new pages, add option to enable hashing of new …
Browse files Browse the repository at this point in the history
…pages [#6]
  • Loading branch information
t0815 committed Sep 6, 2024
1 parent 381d70b commit cb5471b
Show file tree
Hide file tree
Showing 15 changed files with 496 additions and 183 deletions.
6 changes: 6 additions & 0 deletions MyCBZ/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@
<setting name="WhatsNewVersion" serializeAs="String">
<value>0</value>
</setting>
<setting name="CalculateHash" serializeAs="String">
<value>False</value>
</setting>
<setting name="CheckDuplicatePages" serializeAs="String">
<value>False</value>
</setting>
</Win_CBZ.Win_CBZSettings>
<Win_CBZ.CBZMageSettings>
<setting name="TempFolderPath" serializeAs="String">
Expand Down
2 changes: 2 additions & 0 deletions MyCBZ/Data/AddImagesThreadParams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ internal class AddImagesThreadParams : ThreadParam
public string[] FilterExtensions { get; set; } = new string[0];

public int MaxCountPages { get; set; } = 0;

public bool HashFiles { get; set; } = false;
}
}
2 changes: 2 additions & 0 deletions MyCBZ/Data/ParseFilesThreadParams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ internal class ParseFilesThreadParams : ThreadParam

public MetaData.PageIndexVersion PageIndexVerToWrite { get; set; } = MetaData.PageIndexVersion.VERSION_1;

public bool HashFiles { get; set; } = false;

public bool ContinuePipeline { get; set; }
}
}
1 change: 1 addition & 0 deletions MyCBZ/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4898,6 +4898,7 @@ private void SettingsToolStripMenuItem_Click(object sender, EventArgs e)
Win_CBZSettings.Default.OmitEmptyXMLTags = settingsDialog.OmitEmptyXMLTags;
Win_CBZSettings.Default.AutoDeleteTempFiles = settingsDialog.DeleteTempFilesImediately;
Win_CBZSettings.Default.SkipIndexCheck = settingsDialog.SkipIndexCheck;
Win_CBZSettings.Default.CalculateHash = settingsDialog.CalculateCrc32;

Win_CBZSettings.Default.CustomMetadataFields.Clear();
foreach (String line in settingsDialog.CustomFieldTypesCollection)
Expand Down
6 changes: 6 additions & 0 deletions MyCBZ/Forms/PageSettingsForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using System.Drawing.Imaging;
using System.Runtime.Versioning;
using System.Threading;
using Win_CBZ.Hash;

namespace Win_CBZ.Forms
{
Expand Down Expand Up @@ -345,6 +346,11 @@ private void ButtonReloadImage_Click(object sender, EventArgs e)
{
Invoke(new Action(() =>
{
if (Win_CBZ.Win_CBZSettings.Default.CalculateHash)
{
HashCrc32.Calculate(ref FirstPage);
}

ImagePreviewButton.BackgroundImage = Image.FromHbitmap(t.Result.GetHbitmap());

LabelDimensions.Text = FirstPage.Format.W.ToString() + " x " + FirstPage.Format.H.ToString() + " px";
Expand Down
105 changes: 86 additions & 19 deletions MyCBZ/Forms/SettingsDialog.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions MyCBZ/Forms/SettingsDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ internal partial class SettingsDialog : Form

public bool SkipIndexCheck;

public bool CalculateCrc32;

DataValidation validation;

public SettingsDialog()
Expand Down Expand Up @@ -87,6 +89,8 @@ public SettingsDialog()

SkipIndexCheck = Win_CBZSettings.Default.SkipIndexCheck;

CalculateCrc32 = Win_CBZSettings.Default.CalculateHash;

//CustomFieldTypesCollection = Win_CBZSettings.Default.CustomMetadataFields.OfType<String>().ToArray();

CustomFieldTypesSettings = MetaDataFieldConfig.GetInstance().GetAllTypes();
Expand All @@ -106,6 +110,7 @@ public SettingsDialog()

CheckBoxPruneEmplyTags.Checked = OmitEmptyXMLTags;
CheckBoxSkipIndexCheck.Checked = SkipIndexCheck;
CheckBoxCalculateCrc.Checked = CalculateCrc32;

ComboBoxFileName.Text = MetaDataFilename;

Expand Down Expand Up @@ -422,6 +427,7 @@ private void SettingsDialog_FormClosing(object sender, FormClosingEventArgs e)
OmitEmptyXMLTags = CheckBoxPruneEmplyTags.Checked;
DeleteTempFilesImediately = CheckBoxDeleteTempFiles.Checked;
SkipIndexCheck = CheckBoxSkipIndexCheck.Checked;
CalculateCrc32 = CheckBoxCalculateCrc.Checked;
List<String> fieldConfigItems = new List<string>();
foreach (MetaDataFieldType fieldTypeCnf in CustomFieldTypesSettings)
{
Expand Down
Loading

0 comments on commit cb5471b

Please sign in to comment.