Fix download/upload timeout + Fix some warnings
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -20,7 +20,7 @@ namespace OpenSaveCloudClient
|
||||
public AboutBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
serverConnector = ServerConnector.GetInstance();
|
||||
serverConnector = ServerConnector.Instance;
|
||||
}
|
||||
|
||||
private void AboutBox_Load(object sender, EventArgs e)
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace OpenSaveCloudClient
|
||||
public AddGameForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
saveManager = SaveManager.GetInstance();
|
||||
saveManager = SaveManager.Instance;
|
||||
NoCoverLabel.Text = "IGDB is not configured";
|
||||
}
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ namespace OpenSaveCloudClient
|
||||
public AddUser()
|
||||
{
|
||||
InitializeComponent();
|
||||
serverConnector = ServerConnector.GetInstance();
|
||||
taskManager = TaskManager.GetInstance();
|
||||
serverConnector = ServerConnector.Instance;
|
||||
taskManager = TaskManager.Instance;
|
||||
}
|
||||
|
||||
private void AddUser_Load(object sender, EventArgs e)
|
||||
|
||||
@@ -20,11 +20,17 @@ namespace OpenSaveCloudClient.Core
|
||||
messages = new List<Log>();
|
||||
}
|
||||
|
||||
public static LogManager GetInstance()
|
||||
public static LogManager Instance
|
||||
{
|
||||
if (instance == null) { instance = new LogManager(); }
|
||||
get
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
instance = new LogManager();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
public void AddError(Exception ex)
|
||||
{
|
||||
|
||||
@@ -22,7 +22,9 @@ namespace OpenSaveCloudClient.Core
|
||||
ThreadPool.QueueUserWorkItem(delegate { CleanArchiveFolder(); });
|
||||
}
|
||||
|
||||
public static SaveManager GetInstance()
|
||||
public static SaveManager Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
@@ -30,6 +32,7 @@ namespace OpenSaveCloudClient.Core
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
public GameSave Create(string name, string path, string coverHash)
|
||||
{
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace OpenSaveCloudClient.Core
|
||||
|
||||
private readonly LogManager logManager;
|
||||
private readonly TaskManager taskManager;
|
||||
private readonly Configuration configuration;
|
||||
private readonly UserConfiguration configuration;
|
||||
private readonly SaveManager saveManager;
|
||||
|
||||
|
||||
@@ -42,20 +42,22 @@ namespace OpenSaveCloudClient.Core
|
||||
|
||||
private ServerConnector()
|
||||
{
|
||||
configuration = Configuration.GetInstance();
|
||||
logManager = LogManager.GetInstance();
|
||||
taskManager = TaskManager.GetInstance();
|
||||
saveManager = SaveManager.GetInstance();
|
||||
configuration = UserConfiguration.Instance;
|
||||
logManager = LogManager.Instance;
|
||||
taskManager = TaskManager.Instance;
|
||||
saveManager = SaveManager.Instance;
|
||||
}
|
||||
|
||||
public static ServerConnector GetInstance()
|
||||
public static ServerConnector Instance
|
||||
{
|
||||
get {
|
||||
if (instance == null)
|
||||
{
|
||||
instance = new ServerConnector();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// method <c>BindNewServer</c> set the hostname (or ip) and the port of the server and try to connect
|
||||
@@ -441,6 +443,7 @@ namespace OpenSaveCloudClient.Core
|
||||
client.DefaultRequestHeaders.Add("X-Upload-Key", uploadToken);
|
||||
client.DefaultRequestHeaders.Add("X-Game-Save-Hash", newHash);
|
||||
client.DefaultRequestHeaders.Add("X-Hash", hash);
|
||||
client.Timeout = Timeout.InfiniteTimeSpan;
|
||||
HttpResponseMessage response = client.PostAsync(string.Format("{0}:{1}/api/v1/game/upload", host, port), multipartFormContent).Result;
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
@@ -480,6 +483,7 @@ namespace OpenSaveCloudClient.Core
|
||||
using HttpClient client = new();
|
||||
client.DefaultRequestHeaders.Add("Authorization", "bearer " + token);
|
||||
client.DefaultRequestHeaders.Add("X-Upload-Key", uploadToken);
|
||||
client.Timeout = Timeout.InfiniteTimeSpan;
|
||||
HttpResponseMessage response = client.GetAsync(string.Format("{0}:{1}/api/v1/game/download", host, port)).Result;
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace OpenSaveCloudClient.Core
|
||||
|
||||
private TaskManager()
|
||||
{
|
||||
logManager = LogManager.GetInstance();
|
||||
logManager = LogManager.Instance;
|
||||
_tasks = new Dictionary<string, AsyncTaskInformation>();
|
||||
mut = new Mutex();
|
||||
timer = new System.Timers.Timer
|
||||
@@ -32,7 +32,9 @@ namespace OpenSaveCloudClient.Core
|
||||
timer.Start();
|
||||
}
|
||||
|
||||
public static TaskManager GetInstance()
|
||||
public static TaskManager Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
@@ -40,6 +42,7 @@ namespace OpenSaveCloudClient.Core
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
public string StartTask(string label, bool undefined, int progressMax)
|
||||
{
|
||||
|
||||
@@ -28,8 +28,8 @@ namespace OpenSaveCloudClient
|
||||
{
|
||||
InitializeComponent();
|
||||
result = new List<GameSave>();
|
||||
serverConnector = ServerConnector.GetInstance();
|
||||
saveManager = SaveManager.GetInstance();
|
||||
serverConnector = ServerConnector.Instance;
|
||||
saveManager = SaveManager.Instance;
|
||||
}
|
||||
|
||||
private void DownloadGameForm_Load(object sender, EventArgs e)
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace OpenSaveCloudClient
|
||||
public partial class GameLibrary : Form
|
||||
{
|
||||
|
||||
private readonly Configuration _configuration;
|
||||
private readonly UserConfiguration _configuration;
|
||||
private readonly SaveManager saveManager;
|
||||
private readonly TaskManager taskManager;
|
||||
private readonly ServerConnector serverConnector;
|
||||
@@ -17,11 +17,11 @@ namespace OpenSaveCloudClient
|
||||
public GameLibrary()
|
||||
{
|
||||
InitializeComponent();
|
||||
saveManager = SaveManager.GetInstance();
|
||||
taskManager = TaskManager.GetInstance();
|
||||
serverConnector = ServerConnector.GetInstance();
|
||||
_configuration = Configuration.GetInstance();
|
||||
logManager = LogManager.GetInstance();
|
||||
saveManager = SaveManager.Instance;
|
||||
taskManager = TaskManager.Instance;
|
||||
serverConnector = ServerConnector.Instance;
|
||||
_configuration = UserConfiguration.Instance;
|
||||
logManager = LogManager.Instance;
|
||||
|
||||
listViewContextMenu = new ContextMenuStrip();
|
||||
listViewContextMenu.Items.Add("Delete from server").Click += contextMenuDeleteFromServer_Click;
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace OpenSaveCloudClient
|
||||
public LoginForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
serverConnector = ServerConnector.GetInstance();
|
||||
serverConnector = ServerConnector.Instance;
|
||||
}
|
||||
|
||||
private void LoginButton_Click(object sender, EventArgs e)
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace OpenSaveCloudClient
|
||||
public LogsForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
logManager = LogManager.GetInstance();
|
||||
logManager = LogManager.Instance;
|
||||
logManager.NewMessage += logManager_NewError;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,25 +7,28 @@ using System.Text.Json;
|
||||
|
||||
namespace OpenSaveCloudClient.Models
|
||||
{
|
||||
public class Configuration
|
||||
public class UserConfiguration
|
||||
{
|
||||
private static Configuration? instance;
|
||||
private static UserConfiguration? instance;
|
||||
private Dictionary<string, string> _values;
|
||||
|
||||
private Configuration()
|
||||
private UserConfiguration()
|
||||
{
|
||||
_values = new Dictionary<string, string>();
|
||||
Load();
|
||||
}
|
||||
|
||||
public static Configuration GetInstance()
|
||||
public static UserConfiguration Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
instance = new Configuration();
|
||||
instance = new UserConfiguration();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
private void Load()
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Threading.Tasks;
|
||||
using System.IO.Compression;
|
||||
using System.Security.Cryptography;
|
||||
using OpenSaveCloudClient.Core;
|
||||
using System.Globalization;
|
||||
|
||||
namespace OpenSaveCloudClient.Models
|
||||
{
|
||||
@@ -96,7 +97,7 @@ namespace OpenSaveCloudClient.Models
|
||||
byte[]? hashBytes = HashTool.HashDirectory(FolderPath);
|
||||
if (hashBytes == null)
|
||||
{
|
||||
throw new Exception(String.Format("failed to get hash of directory '{0}'", FolderPath));
|
||||
throw new Exception(message: string.Format(CultureInfo.CurrentCulture, "failed to get hash of directory '{0}'", FolderPath));
|
||||
}
|
||||
currentHash = BitConverter.ToString(hashBytes).Replace("-", "");
|
||||
if (currentHash != hash)
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<SignAssembly>True</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>D:\keyPair.snk</AssemblyOriginatorKeyFile>
|
||||
<AnalysisLevel>6.0-all</AnalysisLevel>
|
||||
<Version>1.0.1</Version>
|
||||
<Version>1.0.2</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
|
||||
@@ -14,12 +14,12 @@ namespace OpenSaveCloudClient
|
||||
public partial class SettingsForm : Form
|
||||
{
|
||||
|
||||
private readonly Configuration _configuration;
|
||||
private readonly UserConfiguration _configuration;
|
||||
|
||||
public SettingsForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
_configuration = Configuration.GetInstance();
|
||||
_configuration = UserConfiguration.Instance;
|
||||
InitAndFillFields();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace OpenSaveCloudClient
|
||||
public TasksForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
taskManager = TaskManager.GetInstance();
|
||||
taskManager = TaskManager.Instance;
|
||||
}
|
||||
|
||||
private void AddLVItem(string key, string name, string status, bool undefined, int value, int max)
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace OpenSaveCloudClient
|
||||
public UserForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
serverConnector = ServerConnector.GetInstance();
|
||||
serverConnector = ServerConnector.Instance;
|
||||
}
|
||||
|
||||
private void UserForm_Load(object sender, EventArgs e)
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace OpenSaveCloudClient
|
||||
public UserManagementForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
serverConnector = ServerConnector.GetInstance();
|
||||
serverConnector = ServerConnector.Instance;
|
||||
}
|
||||
|
||||
private void UserSettingsButton_Click(object sender, EventArgs e)
|
||||
|
||||
1
OpenSaveCloudClient/WaitingForm.Designer.cs
generated
1
OpenSaveCloudClient/WaitingForm.Designer.cs
generated
@@ -82,6 +82,5 @@
|
||||
|
||||
private Label label1;
|
||||
private PictureBox LoadingIndicator;
|
||||
private System.Windows.Forms.Timer timer1;
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ namespace OpenSaveCloudClient
|
||||
public WaitingForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
taskManager = TaskManager.GetInstance();
|
||||
taskManager = TaskManager.Instance;
|
||||
taskManager.TaskChanged += OnTaskChanged;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user