Skip to content

Commit

Permalink
V. 1.14.4
Browse files Browse the repository at this point in the history
  • Loading branch information
ComputerElite authored Mar 1, 2021
1 parent 9941f01 commit 7dc9eee
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 8 deletions.
18 changes: 16 additions & 2 deletions C#/BeatSaverAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -434,12 +434,26 @@ internal async Task<BeatSaverAPISong> BeatSaverAPISongKey(string Key)

public BeatSaverAPISong GetBeatSaverAPISongViaKey(String key)
{
return BeatSaverAPISongKey(key).Result;
try
{
BeatSaverAPISong s = BeatSaverAPISongKey(key).Result;
return s;
} catch
{
return new BeatSaverAPISong();
}
}

public BeatSaverAPISong GetBeatSaverAPISongViaHash(String hash)
{
return BeatSaverAPISongHash(hash).Result;
try
{
BeatSaverAPISong s = BeatSaverAPISongHash(hash).Result;
return s;
} catch
{
return new BeatSaverAPISong();
}
}

public BeatSaverAPISong GetBeatSaverAPISong(String HashOrKey)
Expand Down
2 changes: 1 addition & 1 deletion C#/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public partial class MainWindow : Window
{
int MajorV = 1;
int MinorV = 14;
int PatchV = 3;
int PatchV = 4;
Boolean Preview = false;
public static bool log = false;

Expand Down
11 changes: 7 additions & 4 deletions C#/PlaylistEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1298,10 +1298,13 @@ public void SaveAll()
txtbox.ScrollToEnd();
return;
}
File.WriteAllText(exe + "\\tmp\\config.json", JsonSerializer.Serialize(BMBFConfig.Config));
postChanges(exe + "\\tmp\\config.json");
txtbox.AppendText("\n\n" + MainWindow.globalLanguage.playlistEditor.code.saved);
txtbox.ScrollToEnd();
if(BMBFConfig.Config != null)
{
File.WriteAllText(exe + "\\tmp\\config.json", JsonSerializer.Serialize(BMBFConfig.Config));
postChanges(exe + "\\tmp\\config.json");
txtbox.AppendText("\n\n" + MainWindow.globalLanguage.playlistEditor.code.saved);
txtbox.ScrollToEnd();
}
}

public void postChanges(String Config)
Expand Down
6 changes: 5 additions & 1 deletion C#/Songs.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
using System.Text.RegularExpressions;
using ComputerUtils.RegxTemplates;
using ComputerUtils.StringFormatters;
using BMBFManager.Utils;

namespace BMBF_Manager
{
Expand Down Expand Up @@ -707,7 +708,8 @@ private void SelectionChanged(object sender, SelectionChangedEventArgs e)

public String CheckSongZip(String zip)
{
ZipFile.ExtractToDirectory(zip, exe + "\\tmp\\correct");
ZipUtils.ExtractSafe(zip, exe + "\\tmp\\correct");
//ZipFile.ExtractToDirectory(zip, exe + "\\tmp\\correct");
return CheckSong(exe + "\\tmp\\correct");
}

Expand Down Expand Up @@ -860,6 +862,7 @@ public String CheckSong(String folder)

public void MoveOutOfFolder(String FolderToMoveAll, ArrayList found)
{
if (!Directory.Exists(FolderToMoveAll)) return;
foreach (String folder in Directory.GetDirectories(FolderToMoveAll))
{
if (found.Count == 0)
Expand All @@ -870,6 +873,7 @@ public void MoveOutOfFolder(String FolderToMoveAll, ArrayList found)
MoveOutOfFolder(folder, found);
foreach (String file in Directory.GetFiles(folder))
{
if (File.Exists(FolderToMoveAll + "\\" + System.IO.Path.GetFileName(file))) File.Delete(FolderToMoveAll + "\\" + System.IO.Path.GetFileName(file));
File.Move(file, FolderToMoveAll + "\\" + System.IO.Path.GetFileName(file));
}
Directory.Delete(folder);
Expand Down
19 changes: 19 additions & 0 deletions C#/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using ComputerUtils.RegxTemplates;
using System;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Windows.Controls;

namespace BMBFManager.Utils
Expand Down Expand Up @@ -131,4 +133,21 @@ public void getQuestIP(TextBox Quest)
MainWindow.config.IP = Quest.Text;
}
}

public class ZipUtils
{
public static void ExtractSafe(String sourceZip, String destinationFolder)
{
using (ZipArchive archive = ZipFile.OpenRead(sourceZip))
{
foreach (ZipArchiveEntry entry in archive.Entries)
{
String name = entry.FullName;
if (name.EndsWith("/")) continue;
if (name.Contains("/")) Directory.CreateDirectory(destinationFolder + "\\" + System.IO.Path.GetDirectoryName(name));
entry.ExtractToFile(destinationFolder + "\\" + entry.FullName, true);
}
}
}
}
}

0 comments on commit 7dc9eee

Please sign in to comment.