From a082bac2c0582296c1d2da1b58bc2be2eb337d7a Mon Sep 17 00:00:00 2001 From: Gilberto Antonio Date: Sat, 15 Sep 2018 17:25:36 -0300 Subject: [PATCH] User can now select older updates of NSP files (Select menu) so they can be deleted from disk --- Switch Backup Manager/Form1.Designer.cs | 35 +++++++++--- Switch Backup Manager/Form1.cs | 75 +++++++++++++++++++++++++ 2 files changed, 102 insertions(+), 8 deletions(-) diff --git a/Switch Backup Manager/Form1.Designer.cs b/Switch Backup Manager/Form1.Designer.cs index 864e218..5ae10a0 100644 --- a/Switch Backup Manager/Form1.Designer.cs +++ b/Switch Backup Manager/Form1.Designer.cs @@ -369,6 +369,8 @@ private void InitializeComponent() this.toolStripMenuItemSelectSceneEShop = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItemSelectSceneOnEShop = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItemSelectSceneNotOnEShop = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItem97 = new System.Windows.Forms.ToolStripSeparator(); + this.outdatedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem22 = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItemGroupingNoneEShop = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItemGroupingGameTitleEShop = new System.Windows.Forms.ToolStripMenuItem(); @@ -3074,7 +3076,7 @@ private void InitializeComponent() this.toolStripMenuItem97Eshop, this.deleteSelectedFilesToolStripMenuItemEshop}); this.contextMenuEShopList.Name = "contextMenuStripSDCard"; - this.contextMenuEShopList.Size = new System.Drawing.Size(277, 226); + this.contextMenuEShopList.Size = new System.Drawing.Size(277, 204); this.contextMenuEShopList.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStripEShop_Opening); // // toolStripMenuItemEShopShowInExplorer @@ -3340,7 +3342,9 @@ private void InitializeComponent() this.toolStripMenuItemSelectInvertEShop, this.toolStripSeparator7, this.toolStripMenuItemSelectSDCardEShop, - this.toolStripMenuItemSelectSceneEShop}); + this.toolStripMenuItemSelectSceneEShop, + this.toolStripMenuItem97, + this.outdatedToolStripMenuItem}); this.toolStripMenuItemSelectEshop.Name = "toolStripMenuItemSelectEshop"; this.toolStripMenuItemSelectEshop.Size = new System.Drawing.Size(50, 20); this.toolStripMenuItemSelectEshop.Text = "&Select"; @@ -3348,28 +3352,28 @@ private void InitializeComponent() // toolStripMenuItemSelectAllEshop // this.toolStripMenuItemSelectAllEshop.Name = "toolStripMenuItemSelectAllEshop"; - this.toolStripMenuItemSelectAllEshop.Size = new System.Drawing.Size(154, 22); + this.toolStripMenuItemSelectAllEshop.Size = new System.Drawing.Size(180, 22); this.toolStripMenuItemSelectAllEshop.Text = "All"; this.toolStripMenuItemSelectAllEshop.Click += new System.EventHandler(this.toolStripMenuItemSelectAllEshop_Click); // // toolStripMenuItemSelectNoneEShop // this.toolStripMenuItemSelectNoneEShop.Name = "toolStripMenuItemSelectNoneEShop"; - this.toolStripMenuItemSelectNoneEShop.Size = new System.Drawing.Size(154, 22); + this.toolStripMenuItemSelectNoneEShop.Size = new System.Drawing.Size(180, 22); this.toolStripMenuItemSelectNoneEShop.Text = "None"; this.toolStripMenuItemSelectNoneEShop.Click += new System.EventHandler(this.toolStripMenuItemSelectNoneEShop_Click); // // toolStripMenuItemSelectInvertEShop // this.toolStripMenuItemSelectInvertEShop.Name = "toolStripMenuItemSelectInvertEShop"; - this.toolStripMenuItemSelectInvertEShop.Size = new System.Drawing.Size(154, 22); + this.toolStripMenuItemSelectInvertEShop.Size = new System.Drawing.Size(180, 22); this.toolStripMenuItemSelectInvertEShop.Text = "Invert selection"; this.toolStripMenuItemSelectInvertEShop.Click += new System.EventHandler(this.toolStripMenuItemSelectInvertEShop_Click); // // toolStripSeparator7 // this.toolStripSeparator7.Name = "toolStripSeparator7"; - this.toolStripSeparator7.Size = new System.Drawing.Size(151, 6); + this.toolStripSeparator7.Size = new System.Drawing.Size(177, 6); // // toolStripMenuItemSelectSDCardEShop // @@ -3377,7 +3381,7 @@ private void InitializeComponent() this.toolStripMenuItemSelectSDCardItemsOnSDEShop, this.toolStripMenuItemSelectSDCardItemsNotOnSDCardEShop}); this.toolStripMenuItemSelectSDCardEShop.Name = "toolStripMenuItemSelectSDCardEShop"; - this.toolStripMenuItemSelectSDCardEShop.Size = new System.Drawing.Size(154, 22); + this.toolStripMenuItemSelectSDCardEShop.Size = new System.Drawing.Size(180, 22); this.toolStripMenuItemSelectSDCardEShop.Text = "SD card"; // // toolStripMenuItemSelectSDCardItemsOnSDEShop @@ -3400,7 +3404,7 @@ private void InitializeComponent() this.toolStripMenuItemSelectSceneOnEShop, this.toolStripMenuItemSelectSceneNotOnEShop}); this.toolStripMenuItemSelectSceneEShop.Name = "toolStripMenuItemSelectSceneEShop"; - this.toolStripMenuItemSelectSceneEShop.Size = new System.Drawing.Size(154, 22); + this.toolStripMenuItemSelectSceneEShop.Size = new System.Drawing.Size(180, 22); this.toolStripMenuItemSelectSceneEShop.Text = "Scene releases"; this.toolStripMenuItemSelectSceneEShop.Visible = false; // @@ -3409,6 +3413,7 @@ private void InitializeComponent() this.toolStripMenuItemSelectSceneOnEShop.Name = "toolStripMenuItemSelectSceneOnEShop"; this.toolStripMenuItemSelectSceneOnEShop.Size = new System.Drawing.Size(219, 22); this.toolStripMenuItemSelectSceneOnEShop.Text = "Items on Scene releases"; + this.toolStripMenuItemSelectSceneOnEShop.Click += new System.EventHandler(this.toolStripMenuItemSelectSceneOnEShop_Click); // // toolStripMenuItemSelectSceneNotOnEShop // @@ -3416,6 +3421,18 @@ private void InitializeComponent() this.toolStripMenuItemSelectSceneNotOnEShop.Size = new System.Drawing.Size(219, 22); this.toolStripMenuItemSelectSceneNotOnEShop.Text = "Items not on Scene releases"; // + // toolStripMenuItem97 + // + this.toolStripMenuItem97.Name = "toolStripMenuItem97"; + this.toolStripMenuItem97.Size = new System.Drawing.Size(177, 6); + // + // outdatedToolStripMenuItem + // + this.outdatedToolStripMenuItem.Name = "outdatedToolStripMenuItem"; + this.outdatedToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.outdatedToolStripMenuItem.Text = "Outdated updates"; + this.outdatedToolStripMenuItem.Click += new System.EventHandler(this.outdatedToolStripMenuItem_Click); + // // toolStripMenuItem22 // this.toolStripMenuItem22.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -4590,6 +4607,8 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem deleteSelectedFileserasesFromDiskToolStripMenuItemSDCard; private System.Windows.Forms.ToolStripSeparator toolStripMenuItem97LocalFiles; private System.Windows.Forms.ToolStripMenuItem deleteSelectedFileserasesFromDiskToolStripMenuItemLocalFiles; + private System.Windows.Forms.ToolStripSeparator toolStripMenuItem97; + private System.Windows.Forms.ToolStripMenuItem outdatedToolStripMenuItem; } } diff --git a/Switch Backup Manager/Form1.cs b/Switch Backup Manager/Form1.cs index ebb152f..4615cdc 100644 --- a/Switch Backup Manager/Form1.cs +++ b/Switch Backup Manager/Form1.cs @@ -2648,6 +2648,7 @@ private void deleteSelectedFilesToolStripMenuItemEshop_Click(object sender, Even UpdateLocalNSPGamesList(); toolStripStatusLabel1.Text = "0 Selected (0MB)"; } + } private void allFilesToolStripMenuItem1_Click(object sender, EventArgs e) @@ -3999,7 +4000,81 @@ private void deleteSelectedFileserasesFromDiskToolStripMenuItemSDCard_Click(obje OperationDeleteSelectedSDCardFiles(); UpdateSDCardList(); toolStripStatusLabel1.Text = "0 Selected (0MB)"; + MessageBox.Show("Done"); + } + } + + private void outdatedToolStripMenuItem_Click(object sender, EventArgs e) + { + SortedDictionary, FileData> updates = new SortedDictionary, FileData>(); + Dictionary, String> updates_to_delete = new Dictionary, string>(); + + //This gives us a SortedDictionary containing only updates + foreach (FileData file in LocalNSPFilesList.Values) + { + if (file.ContentType == "Patch") + { + try + { + updates.Add(new Tuple(file.TitleID, Convert.ToInt32(file.Version)), file); + } catch (Exception ex) + { + Util.logger.Error("Error on " + file.TitleID + ", " + file.Version); + } + } + } + + int index = 0; + string titleID = updates.ElementAt(0).Value.TitleID; + int version = -1; + try + { + version = Convert.ToInt32(updates.ElementAt(0).Value.Version); + } catch + { + Util.logger.Error("Error on " + titleID + ", " + updates.ElementAt(0).Value.Version); + } + + foreach (FileData file in updates.Values) + { + if (index <= updates.Count - 2) + { + updates_to_delete.Add(new Tuple(file.TitleID, Convert.ToInt32(file.Version)), ""); + } + + if (file.TitleID != titleID) + { + updates_to_delete.Remove(new Tuple(titleID, Convert.ToInt32(version))); + } + + titleID = updates.ElementAt(index).Value.TitleID; + version = Convert.ToInt32(updates.ElementAt(index).Value.Version); + index++; } + + OLVEshop.Select(); + OLVEshop.HideSelection = false; + OLVEshop.SelectedItems.Clear(); + foreach (ListViewItem item in OLVEshop.Items) + { + string dummy; + try + { + if (updates_to_delete.TryGetValue(new Tuple(item.Text, Convert.ToInt32(Convert.ToString(((FileData)((OLVListItem)item).RowObject).Version))), out dummy)) + { + item.Selected = true; + } + } catch + { + //Util.logger.Error("Error on " + item.Text + ", " + Convert.ToString(((FileData)((OLVListItem)item).RowObject).Version)); + } + } +// OLVEshop.RefreshSelectedObjects(); + } + + private void toolStripMenuItemSelectSceneOnEShop_Click(object sender, EventArgs e) + { + } } }