Skip to content

Commit

Permalink
fix: fixup version checking
Browse files Browse the repository at this point in the history
  • Loading branch information
JustSimplyKyle committed Jan 24, 2024
1 parent 7b52379 commit 1648603
Show file tree
Hide file tree
Showing 11 changed files with 274 additions and 234 deletions.
21 changes: 10 additions & 11 deletions app/lib/src/rust/api/shared_resources/collection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ class Collection extends RustOpaque {
advancedOptions: advancedOptions,
hint: hint);

/// Downloads game(alos verifies)
Future<LaunchArgs> downloadGame({dynamic hint}) =>
RustLib.instance.api.collectionDownloadGame(
that: this,
);

Future<PathBuf> gameDirectory({dynamic hint}) =>
RustLib.instance.api.collectionGameDirectory(
that: this,
Expand All @@ -61,19 +55,24 @@ class Collection extends RustOpaque {
that: this,
);

Future<StorageLoader> getLoader({dynamic hint}) =>
RustLib.instance.api.collectionGetLoader(
that: this,
);

/// SIDE-EFFECT: put `launch_args` into Struct
Future<void> launchGame({dynamic hint}) =>
RustLib.instance.api.collectionLaunchGame(
that: this,
);

Future<void> save({dynamic hint}) => RustLib.instance.api.collectionSave(
that: this,
);

static Future<List<StorageLoader>> scan({dynamic hint}) =>
RustLib.instance.api.collectionScan(hint: hint);

/// Downloads game(alos verifies)
Future<LaunchArgs> verifyAndDownloadGame({dynamic hint}) =>
RustLib.instance.api.collectionVerifyAndDownloadGame(
that: this,
);
}

class AdvancedOptions {
Expand Down
91 changes: 45 additions & 46 deletions app/lib/src/rust/frb_generated.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@ abstract class RustLibApi extends BaseApi {
AdvancedOptions? advancedOptions,
dynamic hint});

Future<LaunchArgs> collectionDownloadGame(
{required Collection that, dynamic hint});

Future<PathBuf> collectionGameDirectory(
{required Collection that, dynamic hint});

Expand All @@ -94,13 +91,15 @@ abstract class RustLibApi extends BaseApi {
Future<CollectionId> collectionGetCollectionId(
{required Collection that, dynamic hint});

Future<StorageLoader> collectionGetLoader(
{required Collection that, dynamic hint});

Future<void> collectionLaunchGame({required Collection that, dynamic hint});

Future<void> collectionSave({required Collection that, dynamic hint});

Future<List<StorageLoader>> collectionScan({dynamic hint});

Future<LaunchArgs> collectionVerifyAndDownloadGame(
{required Collection that, dynamic hint});

Future<void> createCollection(
{required String displayName,
required VersionMetadata versionMetadata,
Expand Down Expand Up @@ -211,32 +210,6 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
],
);

@override
Future<LaunchArgs> collectionDownloadGame(
{required Collection that, dynamic hint}) {
return handler.executeNormal(NormalTask(
callFfi: (port_) {
var arg0 =
cst_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockCollection(
that);
return wire.wire_Collection_download_game(port_, arg0);
},
codec: DcoCodec(
decodeSuccessData: dco_decode_launch_args,
decodeErrorData: dco_decode_AnyhowException,
),
constMeta: kCollectionDownloadGameConstMeta,
argValues: [that],
apiImpl: this,
hint: hint,
));
}

TaskConstMeta get kCollectionDownloadGameConstMeta => const TaskConstMeta(
debugName: "Collection_download_game",
argNames: ["that"],
);

@override
Future<PathBuf> collectionGameDirectory(
{required Collection that, dynamic hint}) {
Expand Down Expand Up @@ -314,53 +287,52 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
);

@override
Future<StorageLoader> collectionGetLoader(
{required Collection that, dynamic hint}) {
Future<void> collectionLaunchGame({required Collection that, dynamic hint}) {
return handler.executeNormal(NormalTask(
callFfi: (port_) {
var arg0 =
cst_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockCollection(
cst_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockCollection(
that);
return wire.wire_Collection_get_loader(port_, arg0);
return wire.wire_Collection_launch_game(port_, arg0);
},
codec: DcoCodec(
decodeSuccessData: dco_decode_storage_loader,
decodeSuccessData: dco_decode_unit,
decodeErrorData: dco_decode_AnyhowException,
),
constMeta: kCollectionGetLoaderConstMeta,
constMeta: kCollectionLaunchGameConstMeta,
argValues: [that],
apiImpl: this,
hint: hint,
));
}

TaskConstMeta get kCollectionGetLoaderConstMeta => const TaskConstMeta(
debugName: "Collection_get_loader",
TaskConstMeta get kCollectionLaunchGameConstMeta => const TaskConstMeta(
debugName: "Collection_launch_game",
argNames: ["that"],
);

@override
Future<void> collectionLaunchGame({required Collection that, dynamic hint}) {
Future<void> collectionSave({required Collection that, dynamic hint}) {
return handler.executeNormal(NormalTask(
callFfi: (port_) {
var arg0 =
cst_encode_Auto_RefMut_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockCollection(
cst_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockCollection(
that);
return wire.wire_Collection_launch_game(port_, arg0);
return wire.wire_Collection_save(port_, arg0);
},
codec: DcoCodec(
decodeSuccessData: dco_decode_unit,
decodeErrorData: dco_decode_AnyhowException,
),
constMeta: kCollectionLaunchGameConstMeta,
constMeta: kCollectionSaveConstMeta,
argValues: [that],
apiImpl: this,
hint: hint,
));
}

TaskConstMeta get kCollectionLaunchGameConstMeta => const TaskConstMeta(
debugName: "Collection_launch_game",
TaskConstMeta get kCollectionSaveConstMeta => const TaskConstMeta(
debugName: "Collection_save",
argNames: ["that"],
);

Expand All @@ -386,6 +358,33 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
argNames: [],
);

@override
Future<LaunchArgs> collectionVerifyAndDownloadGame(
{required Collection that, dynamic hint}) {
return handler.executeNormal(NormalTask(
callFfi: (port_) {
var arg0 =
cst_encode_Auto_Ref_RustOpaque_flutter_rust_bridgefor_generatedrust_asyncRwLockCollection(
that);
return wire.wire_Collection_verify_and_download_game(port_, arg0);
},
codec: DcoCodec(
decodeSuccessData: dco_decode_launch_args,
decodeErrorData: dco_decode_AnyhowException,
),
constMeta: kCollectionVerifyAndDownloadGameConstMeta,
argValues: [that],
apiImpl: this,
hint: hint,
));
}

TaskConstMeta get kCollectionVerifyAndDownloadGameConstMeta =>
const TaskConstMeta(
debugName: "Collection_verify_and_download_game",
argNames: ["that"],
);

@override
Future<void> createCollection(
{required String displayName,
Expand Down
57 changes: 29 additions & 28 deletions app/lib/src/rust/frb_generated.io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1242,22 +1242,6 @@ class RustLibWire implements BaseWire {
ffi.Pointer<wire_cst_mod_loader>,
ffi.Pointer<wire_cst_advanced_options>)>();

void wire_Collection_download_game(
int port_,
int that,
) {
return _wire_Collection_download_game(
port_,
that,
);
}

late final _wire_Collection_download_gamePtr =
_lookup<ffi.NativeFunction<ffi.Void Function(ffi.Int64, ffi.UintPtr)>>(
'frbgen_era_connect_wire_Collection_download_game');
late final _wire_Collection_download_game =
_wire_Collection_download_gamePtr.asFunction<void Function(int, int)>();

void wire_Collection_game_directory(
int port_,
int that,
Expand Down Expand Up @@ -1305,37 +1289,37 @@ class RustLibWire implements BaseWire {
_wire_Collection_get_collection_idPtr
.asFunction<void Function(int, int)>();

void wire_Collection_get_loader(
void wire_Collection_launch_game(
int port_,
int that,
) {
return _wire_Collection_get_loader(
return _wire_Collection_launch_game(
port_,
that,
);
}

late final _wire_Collection_get_loaderPtr =
late final _wire_Collection_launch_gamePtr =
_lookup<ffi.NativeFunction<ffi.Void Function(ffi.Int64, ffi.UintPtr)>>(
'frbgen_era_connect_wire_Collection_get_loader');
late final _wire_Collection_get_loader =
_wire_Collection_get_loaderPtr.asFunction<void Function(int, int)>();
'frbgen_era_connect_wire_Collection_launch_game');
late final _wire_Collection_launch_game =
_wire_Collection_launch_gamePtr.asFunction<void Function(int, int)>();

void wire_Collection_launch_game(
void wire_Collection_save(
int port_,
int that,
) {
return _wire_Collection_launch_game(
return _wire_Collection_save(
port_,
that,
);
}

late final _wire_Collection_launch_gamePtr =
late final _wire_Collection_savePtr =
_lookup<ffi.NativeFunction<ffi.Void Function(ffi.Int64, ffi.UintPtr)>>(
'frbgen_era_connect_wire_Collection_launch_game');
late final _wire_Collection_launch_game =
_wire_Collection_launch_gamePtr.asFunction<void Function(int, int)>();
'frbgen_era_connect_wire_Collection_save');
late final _wire_Collection_save =
_wire_Collection_savePtr.asFunction<void Function(int, int)>();

void wire_Collection_scan(
int port_,
Expand All @@ -1351,6 +1335,23 @@ class RustLibWire implements BaseWire {
late final _wire_Collection_scan =
_wire_Collection_scanPtr.asFunction<void Function(int)>();

void wire_Collection_verify_and_download_game(
int port_,
int that,
) {
return _wire_Collection_verify_and_download_game(
port_,
that,
);
}

late final _wire_Collection_verify_and_download_gamePtr =
_lookup<ffi.NativeFunction<ffi.Void Function(ffi.Int64, ffi.UintPtr)>>(
'frbgen_era_connect_wire_Collection_verify_and_download_game');
late final _wire_Collection_verify_and_download_game =
_wire_Collection_verify_and_download_gamePtr
.asFunction<void Function(int, int)>();

void wire_create_collection(
int port_,
ffi.Pointer<wire_cst_list_prim_u_8_strict> display_name,
Expand Down
23 changes: 12 additions & 11 deletions app/lib/src/rust/frb_generated.web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1059,9 +1059,6 @@ class RustLibWire implements BaseWire {
wasmModule.wire_Collection_create(
port_, display_name, version_metadata, mod_loader, advanced_options);

void wire_Collection_download_game(NativePortType port_, Object that) =>
wasmModule.wire_Collection_download_game(port_, that);

void wire_Collection_game_directory(NativePortType port_, Object that) =>
wasmModule.wire_Collection_game_directory(port_, that);

Expand All @@ -1071,15 +1068,19 @@ class RustLibWire implements BaseWire {
void wire_Collection_get_collection_id(NativePortType port_, Object that) =>
wasmModule.wire_Collection_get_collection_id(port_, that);

void wire_Collection_get_loader(NativePortType port_, Object that) =>
wasmModule.wire_Collection_get_loader(port_, that);

void wire_Collection_launch_game(NativePortType port_, Object that) =>
wasmModule.wire_Collection_launch_game(port_, that);

void wire_Collection_save(NativePortType port_, Object that) =>
wasmModule.wire_Collection_save(port_, that);

void wire_Collection_scan(NativePortType port_) =>
wasmModule.wire_Collection_scan(port_);

void wire_Collection_verify_and_download_game(
NativePortType port_, Object that) =>
wasmModule.wire_Collection_verify_and_download_game(port_, that);

void wire_create_collection(
NativePortType port_,
String display_name,
Expand Down Expand Up @@ -1162,9 +1163,6 @@ class RustLibWasmModule implements WasmModule {
List<dynamic>? mod_loader,
List<dynamic>? advanced_options);

external void wire_Collection_download_game(
NativePortType port_, Object that);

external void wire_Collection_game_directory(
NativePortType port_, Object that);

Expand All @@ -1173,12 +1171,15 @@ class RustLibWasmModule implements WasmModule {
external void wire_Collection_get_collection_id(
NativePortType port_, Object that);

external void wire_Collection_get_loader(NativePortType port_, Object that);

external void wire_Collection_launch_game(NativePortType port_, Object that);

external void wire_Collection_save(NativePortType port_, Object that);

external void wire_Collection_scan(NativePortType port_);

external void wire_Collection_verify_and_download_game(
NativePortType port_, Object that);

external void wire_create_collection(
NativePortType port_,
String display_name,
Expand Down
6 changes: 4 additions & 2 deletions app/rust/src/api/backend_exclusive/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::{
use anyhow::{bail, Context};
use bytes::{BufMut, Bytes, BytesMut};
use futures::{future::BoxFuture, StreamExt};
use log::error;
use log::{debug, error};
use reqwest::Url;
use tokio::{
fs::File,
Expand Down Expand Up @@ -171,7 +171,7 @@ pub async fn execute_and_progress(
download_args: DownloadArgs<'_>,
bias: DownloadBias,
) -> anyhow::Result<()> {
println!("run_download");
debug!("receiving download request");
let handles = download_args.handles;
let calculate_speed = download_args.is_size;
let download_complete = Arc::new(AtomicBool::new(false));
Expand All @@ -197,6 +197,8 @@ pub async fn execute_and_progress(
download_complete.store(true, Ordering::Release);
output.await?;

debug!("finish download request");

// DOWNLOAD_PROGRESS.remove(&id);

Ok(())
Expand Down
Loading

0 comments on commit 1648603

Please sign in to comment.