Pointed at gitea.piwalker.net

This commit is contained in:
Samuel Walker 2025-05-03 19:29:36 -06:00
parent 1d7df8854f
commit 9a7a317a11
6 changed files with 21 additions and 19 deletions

View File

@ -3,6 +3,7 @@ package main
import ( import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"fmt"
"time" "time"
) )
@ -24,12 +25,12 @@ type ModpackManager struct {
Modpacks []Modpack Modpacks []Modpack
} }
func (m *ModpackManager) QuerryModpacks() { func (m *ModpackManager) QuerryModpacks() {
m.Modpacks = []Modpack{} m.Modpacks = []Modpack{}
buff := new(bytes.Buffer) buff := new(bytes.Buffer)
err := HttpDownload("modpacks.json", buff, nil) err := HttpDownload("modpacks.json", buff, nil)
if err != nil { if err != nil {
fmt.Printf("HTTP error: %s\n", err)
return return
} }
err = json.Unmarshal(buff.Bytes(), &m.Modpacks) err = json.Unmarshal(buff.Bytes(), &m.Modpacks)
@ -48,7 +49,6 @@ func (m *ModpackManager) QuerryModpacks() {
} }
} }
func (m *ModpackManager) GetModpacks() []Modpack { func (m *ModpackManager) GetModpacks() []Modpack {
return m.Modpacks return m.Modpacks
} }

View File

@ -74,7 +74,7 @@ export namespace main {
export class FabricMeta { export class FabricMeta {
Version: number; Version: number;
Libraries: FabricLibraries; Libraries: FabricLibraries;
MainClass: {[key: string]: string}; MainClass: Record<string, string>;
static createFrom(source: any = {}) { static createFrom(source: any = {}) {
return new FabricMeta(source); return new FabricMeta(source);
@ -332,7 +332,7 @@ export namespace main {
export class QuiltMeta { export class QuiltMeta {
Version: number; Version: number;
Libraries: QuiltLibraries; Libraries: QuiltLibraries;
MainClass: {[key: string]: string}; MainClass: Record<string, string>;
static createFrom(source: any = {}) { static createFrom(source: any = {}) {
return new QuiltMeta(source); return new QuiltMeta(source);

View File

@ -134,7 +134,7 @@ export function WindowIsFullscreen(): Promise<boolean>;
// [WindowSetSize](https://wails.io/docs/reference/runtime/window#windowsetsize) // [WindowSetSize](https://wails.io/docs/reference/runtime/window#windowsetsize)
// Sets the width and height of the window. // Sets the width and height of the window.
export function WindowSetSize(width: number, height: number): Promise<Size>; export function WindowSetSize(width: number, height: number): void;
// [WindowGetSize](https://wails.io/docs/reference/runtime/window#windowgetsize) // [WindowGetSize](https://wails.io/docs/reference/runtime/window#windowgetsize)
// Gets the width and height of the window. // Gets the width and height of the window.

View File

@ -4,7 +4,7 @@ go 1.22.4
toolchain go1.23.2 toolchain go1.23.2
require github.com/wailsapp/wails/v2 v2.9.2 require github.com/wailsapp/wails/v2 v2.10.1
require github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf require github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf

View File

@ -57,8 +57,8 @@ github.com/wailsapp/go-webview2 v1.0.19 h1:7U3QcDj1PrBPaxJNCui2k1SkWml+Q5kvFUFyT
github.com/wailsapp/go-webview2 v1.0.19/go.mod h1:qJmWAmAmaniuKGZPWwne+uor3AHMB5PFhqiK0Bbj8kc= github.com/wailsapp/go-webview2 v1.0.19/go.mod h1:qJmWAmAmaniuKGZPWwne+uor3AHMB5PFhqiK0Bbj8kc=
github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs= github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs=
github.com/wailsapp/mimetype v1.4.1/go.mod h1:9aV5k31bBOv5z6u+QP8TltzvNGJPmNJD4XlAL3U+j3o= github.com/wailsapp/mimetype v1.4.1/go.mod h1:9aV5k31bBOv5z6u+QP8TltzvNGJPmNJD4XlAL3U+j3o=
github.com/wailsapp/wails/v2 v2.9.2 h1:Xb5YRTos1w5N7DTMyYegWaGukCP2fIaX9WF21kPPF2k= github.com/wailsapp/wails/v2 v2.10.1 h1:QWHvWMXII2nI/nXz77gpPG8P3ehl6zKe+u4su5BWIns=
github.com/wailsapp/wails/v2 v2.9.2/go.mod h1:uehvlCwJSFcBq7rMCGfk4rxca67QQGsbg5Nm4m9UnBs= github.com/wailsapp/wails/v2 v2.10.1/go.mod h1:zrebnFV6MQf9kx8HI4iAv63vsR5v67oS7GTEZ7Pz1TY=
github.com/zhyee/zipstream v0.0.0-20230625125559-133d8d1afaa0 h1:BcjUUYzMORs7sJtOCWLXaelG7woHMN1QEs4yCB1QZ48= github.com/zhyee/zipstream v0.0.0-20230625125559-133d8d1afaa0 h1:BcjUUYzMORs7sJtOCWLXaelG7woHMN1QEs4yCB1QZ48=
github.com/zhyee/zipstream v0.0.0-20230625125559-133d8d1afaa0/go.mod h1:aaGtAo3dTqYtHjcliPNlyXMIIodvGm8y6uK2KMTYHrk= github.com/zhyee/zipstream v0.0.0-20230625125559-133d8d1afaa0/go.mod h1:aaGtAo3dTqYtHjcliPNlyXMIIodvGm8y6uK2KMTYHrk=
golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus= golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus=

View File

@ -2,6 +2,7 @@ package main
import ( import (
"context" "context"
"fmt"
"io" "io"
"net/http" "net/http"
"strings" "strings"
@ -13,13 +14,13 @@ const BlockSize = 1024 * 64
func HttpDownload(path string, out io.Writer, ctx context.Context) error { func HttpDownload(path string, out io.Writer, ctx context.Context) error {
path = strings.ReplaceAll(path, "\\", "/") path = strings.ReplaceAll(path, "\\", "/")
res, err := http.Get("https://fclauncher.piwalker.net/fclauncher/" + path) res, err := http.Get("https://gitea.piwalker.net/fclauncher/" + path)
if err != nil { if err != nil {
return err return err
} }
defer res.Body.Close() defer res.Body.Close()
var read int64 = 0 var read int64 = 0
for read < res.ContentLength { for (read < res.ContentLength) || res.ContentLength == -1 {
count, err := io.CopyN(out, res.Body, BlockSize) count, err := io.CopyN(out, res.Body, BlockSize)
read += count read += count
if err != nil { if err != nil {
@ -32,5 +33,6 @@ func HttpDownload(path string, out io.Writer, ctx context.Context) error {
if ctx != nil { if ctx != nil {
runtime.EventsEmit(ctx, "download_complete") runtime.EventsEmit(ctx, "download_complete")
} }
fmt.Printf("Downloaded %d Bytes from %s, expected %d Bytes\n", read, path, res.ContentLength)
return nil return nil
} }