From bac0ca0cca119ff93475bb0354162ba22cceab11 Mon Sep 17 00:00:00 2001 From: weberonede Date: Wed, 4 Sep 2019 11:11:01 +0200 Subject: [PATCH 1/3] #6 Fix too short pathfield ListBox that shows the paths is now bigger + added horizontal scrollbar. --- KPSimpleBackup/SettingsForm.Designer.cs | 209 ++++++++++++------------ 1 file changed, 105 insertions(+), 104 deletions(-) diff --git a/KPSimpleBackup/SettingsForm.Designer.cs b/KPSimpleBackup/SettingsForm.Designer.cs index 763392b..e193659 100644 --- a/KPSimpleBackup/SettingsForm.Designer.cs +++ b/KPSimpleBackup/SettingsForm.Designer.cs @@ -31,11 +31,16 @@ private void InitializeComponent() this.panel1 = new System.Windows.Forms.Panel(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.label1 = new System.Windows.Forms.Label(); + this.numericNumberOfBackups = new System.Windows.Forms.NumericUpDown(); + this.label2 = new System.Windows.Forms.Label(); this.panel2 = new System.Windows.Forms.Panel(); + this.buttonRemoveSelectedFolder = new System.Windows.Forms.Button(); this.listBoxBackupPaths = new System.Windows.Forms.ListBox(); this.buttonAddFolder = new System.Windows.Forms.Button(); - this.numericNumberOfBackups = new System.Windows.Forms.NumericUpDown(); - this.label2 = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.panel3 = new System.Windows.Forms.Panel(); + this.buttonDateFormatHelp = new System.Windows.Forms.Button(); + this.textBoxDateFormat = new System.Windows.Forms.TextBox(); this.buttonSave = new System.Windows.Forms.Button(); this.checkBoxUseDbName = new System.Windows.Forms.CheckBox(); this.tabControlSettings = new System.Windows.Forms.TabControl(); @@ -44,24 +49,19 @@ private void InitializeComponent() this.checkBoxAutoBackup = new System.Windows.Forms.CheckBox(); this.label3 = new System.Windows.Forms.Label(); this.checkBoxUseRecycleBin = new System.Windows.Forms.CheckBox(); - this.buttonRemoveSelectedFolder = new System.Windows.Forms.Button(); this.tabPage3 = new System.Windows.Forms.TabPage(); - this.label4 = new System.Windows.Forms.Label(); - this.labelVersion = new System.Windows.Forms.Label(); - this.label5 = new System.Windows.Forms.Label(); - this.panel3 = new System.Windows.Forms.Panel(); - this.textBoxDateFormat = new System.Windows.Forms.TextBox(); - this.buttonDateFormatHelp = new System.Windows.Forms.Button(); this.linkLabelReportBug = new System.Windows.Forms.LinkLabel(); + this.labelVersion = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); this.panel1.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout(); - this.panel2.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericNumberOfBackups)).BeginInit(); + this.panel2.SuspendLayout(); + this.panel3.SuspendLayout(); this.tabControlSettings.SuspendLayout(); this.tabPage1.SuspendLayout(); this.tabPage2.SuspendLayout(); this.tabPage3.SuspendLayout(); - this.panel3.SuspendLayout(); this.SuspendLayout(); // // panel1 @@ -69,7 +69,7 @@ private void InitializeComponent() this.panel1.Controls.Add(this.tableLayoutPanel1); this.panel1.Location = new System.Drawing.Point(6, 6); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(420, 239); + this.panel1.Size = new System.Drawing.Size(515, 317); this.panel1.TabIndex = 0; // // tableLayoutPanel1 @@ -91,7 +91,7 @@ private void InitializeComponent() this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 37F)); - this.tableLayoutPanel1.Size = new System.Drawing.Size(414, 233); + this.tableLayoutPanel1.Size = new System.Drawing.Size(509, 311); this.tableLayoutPanel1.TabIndex = 3; // // label1 @@ -104,23 +104,52 @@ private void InitializeComponent() this.label1.TabIndex = 1; this.label1.Text = "Number of backups to keep:"; // + // numericNumberOfBackups + // + this.numericNumberOfBackups.Location = new System.Drawing.Point(188, 4); + this.numericNumberOfBackups.Name = "numericNumberOfBackups"; + this.numericNumberOfBackups.Size = new System.Drawing.Size(317, 20); + this.numericNumberOfBackups.TabIndex = 5; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(4, 43); + this.label2.Margin = new System.Windows.Forms.Padding(3, 15, 3, 0); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(114, 13); + this.label2.TabIndex = 3; + this.label2.Text = "Folder for backup files:"; + // // panel2 // this.panel2.Controls.Add(this.buttonRemoveSelectedFolder); this.panel2.Controls.Add(this.listBoxBackupPaths); this.panel2.Controls.Add(this.buttonAddFolder); - this.panel2.Location = new System.Drawing.Point(154, 31); + this.panel2.Location = new System.Drawing.Point(188, 31); this.panel2.Name = "panel2"; - this.panel2.Size = new System.Drawing.Size(256, 158); + this.panel2.Size = new System.Drawing.Size(317, 238); this.panel2.TabIndex = 4; // + // buttonRemoveSelectedFolder + // + this.buttonRemoveSelectedFolder.Enabled = false; + this.buttonRemoveSelectedFolder.Location = new System.Drawing.Point(176, 2); + this.buttonRemoveSelectedFolder.Name = "buttonRemoveSelectedFolder"; + this.buttonRemoveSelectedFolder.Size = new System.Drawing.Size(138, 23); + this.buttonRemoveSelectedFolder.TabIndex = 5; + this.buttonRemoveSelectedFolder.Text = "Remove selected folder"; + this.buttonRemoveSelectedFolder.UseVisualStyleBackColor = true; + this.buttonRemoveSelectedFolder.Click += new System.EventHandler(this.buttonRemoveSelectedFolder_Click); + // // listBoxBackupPaths // this.listBoxBackupPaths.FormattingEnabled = true; + this.listBoxBackupPaths.HorizontalScrollbar = true; this.listBoxBackupPaths.Location = new System.Drawing.Point(3, 32); this.listBoxBackupPaths.Name = "listBoxBackupPaths"; this.listBoxBackupPaths.ScrollAlwaysVisible = true; - this.listBoxBackupPaths.Size = new System.Drawing.Size(250, 121); + this.listBoxBackupPaths.Size = new System.Drawing.Size(311, 199); this.listBoxBackupPaths.TabIndex = 4; this.listBoxBackupPaths.SelectedIndexChanged += new System.EventHandler(this.listBoxBackupPaths_SelectedIndexChanged); // @@ -134,26 +163,46 @@ private void InitializeComponent() this.buttonAddFolder.UseVisualStyleBackColor = true; this.buttonAddFolder.Click += new System.EventHandler(this.buttonAddFolder_Click); // - // numericNumberOfBackups + // label5 // - this.numericNumberOfBackups.Location = new System.Drawing.Point(154, 4); - this.numericNumberOfBackups.Name = "numericNumberOfBackups"; - this.numericNumberOfBackups.Size = new System.Drawing.Size(256, 20); - this.numericNumberOfBackups.TabIndex = 5; + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(4, 283); + this.label5.Margin = new System.Windows.Forms.Padding(3, 10, 3, 0); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(65, 13); + this.label5.TabIndex = 6; + this.label5.Text = "Date format:"; // - // label2 + // panel3 // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(4, 43); - this.label2.Margin = new System.Windows.Forms.Padding(3, 15, 3, 0); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(114, 13); - this.label2.TabIndex = 3; - this.label2.Text = "Folder for backup files:"; + this.panel3.Controls.Add(this.buttonDateFormatHelp); + this.panel3.Controls.Add(this.textBoxDateFormat); + this.panel3.Location = new System.Drawing.Point(188, 276); + this.panel3.Name = "panel3"; + this.panel3.Size = new System.Drawing.Size(317, 31); + this.panel3.TabIndex = 7; + // + // buttonDateFormatHelp + // + this.buttonDateFormatHelp.Location = new System.Drawing.Point(294, 4); + this.buttonDateFormatHelp.Name = "buttonDateFormatHelp"; + this.buttonDateFormatHelp.Size = new System.Drawing.Size(20, 20); + this.buttonDateFormatHelp.TabIndex = 1; + this.buttonDateFormatHelp.Text = "?"; + this.buttonDateFormatHelp.UseVisualStyleBackColor = true; + this.buttonDateFormatHelp.Click += new System.EventHandler(this.buttonDateFormatHelp_Click); + // + // textBoxDateFormat + // + this.textBoxDateFormat.Location = new System.Drawing.Point(3, 4); + this.textBoxDateFormat.Name = "textBoxDateFormat"; + this.textBoxDateFormat.Size = new System.Drawing.Size(285, 20); + this.textBoxDateFormat.TabIndex = 0; + this.textBoxDateFormat.TextChanged += new System.EventHandler(this.textBoxDateFormat_TextChanged); // // buttonSave // - this.buttonSave.Location = new System.Drawing.Point(377, 291); + this.buttonSave.Location = new System.Drawing.Point(472, 373); this.buttonSave.Name = "buttonSave"; this.buttonSave.Size = new System.Drawing.Size(75, 23); this.buttonSave.TabIndex = 2; @@ -180,7 +229,7 @@ private void InitializeComponent() this.tabControlSettings.Location = new System.Drawing.Point(12, 12); this.tabControlSettings.Name = "tabControlSettings"; this.tabControlSettings.SelectedIndex = 0; - this.tabControlSettings.Size = new System.Drawing.Size(440, 277); + this.tabControlSettings.Size = new System.Drawing.Size(535, 355); this.tabControlSettings.TabIndex = 1; // // tabPage1 @@ -189,7 +238,7 @@ private void InitializeComponent() this.tabPage1.Location = new System.Drawing.Point(4, 22); this.tabPage1.Name = "tabPage1"; this.tabPage1.Padding = new System.Windows.Forms.Padding(3); - this.tabPage1.Size = new System.Drawing.Size(432, 251); + this.tabPage1.Size = new System.Drawing.Size(527, 329); this.tabPage1.TabIndex = 0; this.tabPage1.Text = "General"; this.tabPage1.UseVisualStyleBackColor = true; @@ -239,17 +288,6 @@ private void InitializeComponent() ")"; this.checkBoxUseRecycleBin.UseVisualStyleBackColor = true; // - // buttonRemoveSelectedFolder - // - this.buttonRemoveSelectedFolder.Enabled = false; - this.buttonRemoveSelectedFolder.Location = new System.Drawing.Point(116, 3); - this.buttonRemoveSelectedFolder.Name = "buttonRemoveSelectedFolder"; - this.buttonRemoveSelectedFolder.Size = new System.Drawing.Size(138, 23); - this.buttonRemoveSelectedFolder.TabIndex = 5; - this.buttonRemoveSelectedFolder.Text = "Remove selected folder"; - this.buttonRemoveSelectedFolder.UseVisualStyleBackColor = true; - this.buttonRemoveSelectedFolder.Click += new System.EventHandler(this.buttonRemoveSelectedFolder_Click); - // // tabPage3 // this.tabPage3.Controls.Add(this.linkLabelReportBug); @@ -262,63 +300,6 @@ private void InitializeComponent() this.tabPage3.Text = "About"; this.tabPage3.UseVisualStyleBackColor = true; // - // label4 - // - this.label4.AutoSize = true; - this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label4.Location = new System.Drawing.Point(3, 10); - this.label4.Margin = new System.Windows.Forms.Padding(3, 10, 3, 0); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(191, 25); - this.label4.TabIndex = 0; - this.label4.Text = "KPSimpleBackup"; - // - // labelVersion - // - this.labelVersion.AutoSize = true; - this.labelVersion.Location = new System.Drawing.Point(8, 39); - this.labelVersion.Name = "labelVersion"; - this.labelVersion.Size = new System.Drawing.Size(42, 13); - this.labelVersion.TabIndex = 1; - this.labelVersion.Text = "Version"; - // - // label5 - // - this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(4, 205); - this.label5.Margin = new System.Windows.Forms.Padding(3, 10, 3, 0); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(65, 13); - this.label5.TabIndex = 6; - this.label5.Text = "Date format:"; - // - // panel3 - // - this.panel3.Controls.Add(this.buttonDateFormatHelp); - this.panel3.Controls.Add(this.textBoxDateFormat); - this.panel3.Location = new System.Drawing.Point(154, 198); - this.panel3.Name = "panel3"; - this.panel3.Size = new System.Drawing.Size(256, 31); - this.panel3.TabIndex = 7; - // - // textBoxDateFormat - // - this.textBoxDateFormat.Location = new System.Drawing.Point(3, 4); - this.textBoxDateFormat.Name = "textBoxDateFormat"; - this.textBoxDateFormat.Size = new System.Drawing.Size(227, 20); - this.textBoxDateFormat.TabIndex = 0; - this.textBoxDateFormat.TextChanged += new System.EventHandler(this.textBoxDateFormat_TextChanged); - // - // buttonDateFormatHelp - // - this.buttonDateFormatHelp.Location = new System.Drawing.Point(233, 4); - this.buttonDateFormatHelp.Name = "buttonDateFormatHelp"; - this.buttonDateFormatHelp.Size = new System.Drawing.Size(20, 20); - this.buttonDateFormatHelp.TabIndex = 1; - this.buttonDateFormatHelp.Text = "?"; - this.buttonDateFormatHelp.UseVisualStyleBackColor = true; - this.buttonDateFormatHelp.Click += new System.EventHandler(this.buttonDateFormatHelp_Click); - // // linkLabelReportBug // this.linkLabelReportBug.ActiveLinkColor = System.Drawing.Color.DarkRed; @@ -332,11 +313,31 @@ private void InitializeComponent() this.linkLabelReportBug.Text = "Report Bug"; this.linkLabelReportBug.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabelReportBug_LinkClicked); // + // labelVersion + // + this.labelVersion.AutoSize = true; + this.labelVersion.Location = new System.Drawing.Point(8, 39); + this.labelVersion.Name = "labelVersion"; + this.labelVersion.Size = new System.Drawing.Size(42, 13); + this.labelVersion.TabIndex = 1; + this.labelVersion.Text = "Version"; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label4.Location = new System.Drawing.Point(3, 10); + this.label4.Margin = new System.Windows.Forms.Padding(3, 10, 3, 0); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(191, 25); + this.label4.TabIndex = 0; + this.label4.Text = "KPSimpleBackup"; + // // SettingsForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(464, 318); + this.ClientSize = new System.Drawing.Size(559, 408); this.Controls.Add(this.tabControlSettings); this.Controls.Add(this.buttonSave); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; @@ -348,16 +349,16 @@ private void InitializeComponent() this.panel1.ResumeLayout(false); this.tableLayoutPanel1.ResumeLayout(false); this.tableLayoutPanel1.PerformLayout(); - this.panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.numericNumberOfBackups)).EndInit(); + this.panel2.ResumeLayout(false); + this.panel3.ResumeLayout(false); + this.panel3.PerformLayout(); this.tabControlSettings.ResumeLayout(false); this.tabPage1.ResumeLayout(false); this.tabPage2.ResumeLayout(false); this.tabPage2.PerformLayout(); this.tabPage3.ResumeLayout(false); this.tabPage3.PerformLayout(); - this.panel3.ResumeLayout(false); - this.panel3.PerformLayout(); this.ResumeLayout(false); } From 68f1f27fd6e8585e575b70d6274c25a13d70edb9 Mon Sep 17 00:00:00 2001 From: marvinweber Date: Wed, 4 Sep 2019 14:34:05 +0200 Subject: [PATCH 2/3] #5 Fix removal of original file by cleanup - fixed search pattern for backup-files - added additional check for original database path -> will not be deleted --- KPSimpleBackup/KPSimpleBackup.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/KPSimpleBackup/KPSimpleBackup.cs b/KPSimpleBackup/KPSimpleBackup.cs index a047ef7..e116939 100644 --- a/KPSimpleBackup/KPSimpleBackup.cs +++ b/KPSimpleBackup/KPSimpleBackup.cs @@ -116,7 +116,7 @@ private void BackupAction(PwDatabase database) String dateTimeFormat = this.m_config.DateFormat; string time = DateTime.Now.ToString(dateTimeFormat); - // Save backup database for each specified path + // Save backup database for each specified path and perform cleanup foreach (String backupFolderPath in paths) { string dbBackupFileName = this.GetBackupFileName(database); @@ -127,7 +127,7 @@ private void BackupAction(PwDatabase database) database.SaveAs(connection, false, null); // Cleanup - this.Cleanup(backupFolderPath, dbBackupFileName); + this.Cleanup(backupFolderPath, dbBackupFileName, database.IOConnectionInfo.Path); } } @@ -146,13 +146,13 @@ private String GetBackupFileName(PwDatabase database) return backupFileName; } - private void Cleanup(String path, String fileNamePrefix) + private void Cleanup(String path, String fileNamePrefix, String originalDatabasePath) { - int filesToKeepAmount = (int)this.m_config.FileAmountToKeep; - // read from settings wether to use recycle bin or delete files permanently + int filesToKeepAmount = (int) this.m_config.FileAmountToKeep; + // read from settings whether to use recycle bin or delete files permanently var recycleOption = this.m_config.UseRecycleBinDeletedBackups ? RecycleOption.SendToRecycleBin : RecycleOption.DeletePermanently; - String searchPattern = fileNamePrefix + "*" + ".kdbx"; + String searchPattern = fileNamePrefix + "_*.kdbx"; String[] fileList = Directory.GetFiles(path, searchPattern).OrderBy(f => f).Reverse().ToArray(); // if more backup files available than needed loop through the unnecessary ones and remove them @@ -160,6 +160,12 @@ private void Cleanup(String path, String fileNamePrefix) { for (int i = filesToKeepAmount; i < fileList.Count(); i++) { + // never delete original file -> always skip it (in case it made it in the filelist) + if (fileList[i].Equals(originalDatabasePath)) + { + continue; + } + FileSystem.DeleteFile(fileList[i], UIOption.OnlyErrorDialogs, recycleOption); } } From 54553219113c15bcd7b47fe1fe4e817d7df83eb5 Mon Sep 17 00:00:00 2001 From: marvinweber Date: Wed, 4 Sep 2019 14:47:07 +0200 Subject: [PATCH 3/3] Prepare for new release --- KPSimpleBackup/KPSimpleBackup.cs | 2 +- KPSimpleBackup/Properties/AssemblyInfo.cs | 4 ++-- kpsimplebackup.version | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/KPSimpleBackup/KPSimpleBackup.cs b/KPSimpleBackup/KPSimpleBackup.cs index e116939..e9e6d16 100644 --- a/KPSimpleBackup/KPSimpleBackup.cs +++ b/KPSimpleBackup/KPSimpleBackup.cs @@ -41,7 +41,7 @@ public override string UpdateUrl { get { - return "https://raw.githubusercontent.com/weberonede/KPSimpleBackup/master/kpsimplebackup.version"; + return "https://raw.githubusercontent.com/marvinweber/KPSimpleBackup/master/kpsimplebackup.version"; } } diff --git a/KPSimpleBackup/Properties/AssemblyInfo.cs b/KPSimpleBackup/Properties/AssemblyInfo.cs index 8e6500a..134c015 100644 --- a/KPSimpleBackup/Properties/AssemblyInfo.cs +++ b/KPSimpleBackup/Properties/AssemblyInfo.cs @@ -33,7 +33,7 @@ // Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, // indem Sie "*" wie unten gezeigt eingeben: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.1.0.0")] -[assembly: AssemblyFileVersion("1.1.0.0")] +[assembly: AssemblyVersion("1.1.1.0")] +[assembly: AssemblyFileVersion("1.1.1.0")] [assembly: NeutralResourcesLanguage("en")] diff --git a/kpsimplebackup.version b/kpsimplebackup.version index 4f8b620..7b5c098 100644 --- a/kpsimplebackup.version +++ b/kpsimplebackup.version @@ -1,3 +1,3 @@ : -KPSimpleBackup:1.1.0 +KPSimpleBackup:1.1.1 : \ No newline at end of file