Skip to content

Commit

Permalink
User can now select older updates of NSP files (Select menu) so they …
Browse files Browse the repository at this point in the history
…can be deleted from disk
  • Loading branch information
gibaBR committed Sep 15, 2018
1 parent 6f1c13d commit a082bac
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 8 deletions.
35 changes: 27 additions & 8 deletions Switch Backup Manager/Form1.Designer.cs

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

75 changes: 75 additions & 0 deletions Switch Backup Manager/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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<Tuple<String, int>, FileData> updates = new SortedDictionary<Tuple<string, int>, FileData>();
Dictionary<Tuple<String, int>, String> updates_to_delete = new Dictionary<Tuple<String, int>, string>();

//This gives us a SortedDictionary containing only updates
foreach (FileData file in LocalNSPFilesList.Values)
{
if (file.ContentType == "Patch")
{
try
{
updates.Add(new Tuple<string, int>(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<string, int>(file.TitleID, Convert.ToInt32(file.Version)), "");
}

if (file.TitleID != titleID)
{
updates_to_delete.Remove(new Tuple<string, int>(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<string, int>(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)
{

}
}
}

0 comments on commit a082bac

Please sign in to comment.