BuildUploadList()
+ {
+ var patcherFile = new FileInfo(_options.OutputPatchPath + ".zip");
+
+ if (!patcherFile.Exists) return false;
+
+ if (_settings.UsingMega() && _options.UploadToMega)
+ {
+ var mega = new MegaUpload(patcherFile, _settings.MegaEmail, _settings.MegaPassword);
+ await mega.SetUploadFolder(_settings.MegaUploadFolder);
+ _fileUploads.Add(mega);
+ }
+
+ if(_settings.UsingGoFile() && _options.UploadToGoFile)
+ {
+ var gofile = new GoFileUpload(patcherFile, _settings.GoFileApiKey);
+ _fileUploads.Add(gofile);
+ }
+
+ return true;
+ }
+
+ private void CreateHubEntrySource()
+ {
+ var goFile = _fileUploads.SingleOrDefault(x => x.GetType() == typeof(GoFileUpload));
+ var mega = _fileUploads.SingleOrDefault(x => x.GetType() == typeof(MegaUpload));
+
+ if(goFile == null || mega == null)
+ {
+ AnsiConsole.WriteLine("Failed to get required info to create hub entry source");
+ return;
+ }
+
+ var goFileLink = goFile.GetLink();
+ var megaLink = mega.GetLink();
+
+ if(goFileLink == null || megaLink == null)
+ {
+ AnsiConsole.WriteLine("Failed to get link for uploaded files");
+ return;
+ }
+
+ string output = $"Downgrade EFT Client files from version {_options.SourceClient.Version} to {_options.TargetClient.Version}
\n
";
+
+ if(_options.UploadToGoFile)
+ {
+ output += $"\nDownload From GoFile
";
+ }
+
+ if(_options.UploadToMega)
+ {
+ output += $"\nDownload From Mega
";
+ }
+
+ AnsiConsole.WriteLine(output);
+
+ var unixTimestamp = (int)DateTime.UtcNow.Subtract(DateTime.UnixEpoch).TotalSeconds;
+
+ string outputPath = $"{Environment.CurrentDirectory}\\hubEntry_{unixTimestamp}.txt";
+ File.WriteAllText(outputPath, output);
+
+ if(File.Exists(outputPath))
+ {
+ AnsiConsole.MarkupLine($"[green]Hub Entry Source saved: {outputPath.EscapeMarkup()}[/]");
+ }
+ else
+ {
+ AnsiConsole.MarkupLine($"[red]Hub Entry Source saved failed[/]");
+ }
+ }
+
+ private async Task UploadAllFiles()
+ {
+ if(!await BuildUploadList())
+ {
+ return false;
+ }
+
+ var succeeded = await AnsiConsole.Progress().Columns(
+ new TaskDescriptionColumn() { Alignment = Justify.Left},
+ new ProgressBarColumn(),
+ new PercentageColumn(),
+ new RemainingTimeColumn(),
+ new SpinnerColumn(Spinner.Known.Dots2)
+ ).StartAsync(async context =>
+ {
+ foreach(var file in _fileUploads)
+ {
+ var task = context.AddTask($"[purple][[Pending]][/] {file.DisplayName}");
+ task.IsIndeterminate = true;
+ uploadTasks.Add(file, task);
+ }
+
+ foreach(var pair in uploadTasks)
+ {
+ // set the value of the progress task object
+ var progress = new System.Progress((d) => pair.Value.Value = d);
+
+ pair.Value.IsIndeterminate = false;
+ pair.Value.Description = pair.Key.DisplayName;
+
+ if(!await pair.Key.UploadAsync(progress))
+ {
+ AnsiConsole.MarkupLine($"[red]{pair.Key.DisplayName.EscapeMarkup()} failed[/]");
+ return false;
+ }
+ }
+
+ return true;
+ });
+
+ return succeeded;
+ }
+
+ public void Run()
+ {
+ if (!_options.CreateRelease)
+ {
+ UploadAllFiles().GetAwaiter().GetResult().ValidateOrExit();
+ }
+
+ CreateHubEntrySource();
+ }
+ }
+}
diff --git a/EftPatchHelper/EftPatchHelper/settings.json b/EftPatchHelper/EftPatchHelper/settings.json
index 1631198..5e20433 100644
--- a/EftPatchHelper/EftPatchHelper/settings.json
+++ b/EftPatchHelper/EftPatchHelper/settings.json
@@ -9,5 +9,9 @@
"giteaApiBasePath": "", //You can leave the gitea settings blank if you don't need to create releases on gitea
"giteaApiKey": "",
"giteaReleaseRepoOwner": "",
- "giteaReleaseRepoName": ""
+ "giteaReleaseRepoName": "",
+ "megaEmail": "",
+ "megaPassword": "",
+ "megaUploadFolder": "",
+ "goFileApiKey": ""
}
\ No newline at end of file