Refactor: Fix slow initial server start
Moved hashing to first update check
This commit is contained in:
parent
48ffb70544
commit
317df007d4
7 changed files with 30 additions and 13 deletions
|
@ -1 +1 @@
|
|||
1.1.010425.1723
|
||||
1.1.010425.1748
|
|
@ -83,7 +83,7 @@ void main() async {
|
|||
await doDownloadMods(false);
|
||||
|
||||
print("Scanning mods...");
|
||||
settings.inst!.mods = await doScanMods(false);
|
||||
settings.inst!.mods = await doScanMods(false, computeHashes: false);
|
||||
settings.Write();
|
||||
|
||||
print("Starting scheduler...");
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class Consts {
|
||||
static const VERSION = "1.1.010425.1723";
|
||||
static const VERSION = "1.1.010425.1748";
|
||||
static const MF_VER_URL =
|
||||
"https://git.zontreck.com/AriasCreations/ConanServerManager/raw/branch/master/MASTER_FILE";
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ Future<void> doDownloadMods(bool jail) async {
|
|||
settings.isDownloadingMods = false;
|
||||
}
|
||||
|
||||
Future<List<Mod>> doScanMods(bool jail) async {
|
||||
Future<List<Mod>> doScanMods(bool jail, {bool computeHashes = false}) async {
|
||||
Settings settings = Settings();
|
||||
|
||||
List<Mod> ret = [];
|
||||
|
@ -68,16 +68,19 @@ Future<List<Mod>> doScanMods(bool jail) async {
|
|||
await for (var entity in dir.list()) {
|
||||
if (entity is File && entity.path.endsWith("pak")) {
|
||||
String name = entity.path.split(Platform.pathSeparator).last;
|
||||
String hash = "";
|
||||
|
||||
var content = await entity.readAsBytes();
|
||||
var data = md5.convert(content);
|
||||
var hash = data.toString();
|
||||
if (jail || computeHashes) {
|
||||
var content = await entity.readAsBytes();
|
||||
var data = md5.convert(content);
|
||||
hash = data.toString();
|
||||
|
||||
//M.mod_pak = name;
|
||||
//M.mod_hash = hash;
|
||||
//M.mod_pak = name;
|
||||
//M.mod_hash = hash;
|
||||
|
||||
print("Discovered mod file: $name");
|
||||
print("Hash: $hash");
|
||||
print("Discovered mod file: $name");
|
||||
print("Hash: $hash");
|
||||
}
|
||||
|
||||
// Update the mod instance, and retain the original modlist order
|
||||
ret.add(Mod(
|
||||
|
|
|
@ -350,7 +350,19 @@ class StateMachine {
|
|||
timer.cancel();
|
||||
|
||||
await doDownloadMods(true);
|
||||
List<Mod> currentMods = await doScanMods(true);
|
||||
if (SessionData.IS_FIRST_MOD_CHECK) {
|
||||
List<Mod> actualMods =
|
||||
await doScanMods(false, computeHashes: true);
|
||||
settings.inst!.mods = actualMods;
|
||||
|
||||
settings
|
||||
.Write(); // Write the settings file to disk after this scan has completed.
|
||||
|
||||
SessionData.IS_FIRST_MOD_CHECK = false;
|
||||
}
|
||||
|
||||
List<Mod> currentMods =
|
||||
await doScanMods(true, computeHashes: true);
|
||||
List<String> updatedMods = [];
|
||||
for (int i = 0; i < currentMods.length; i++) {
|
||||
Mod currentMod = settings.inst!.mods[i];
|
||||
|
|
|
@ -45,4 +45,6 @@ class SessionData {
|
|||
///
|
||||
/// Use the [Settings.getWorldSnapshotFiles] function instead
|
||||
static List<String> IE_SNAPSHOTS = [];
|
||||
|
||||
static bool IS_FIRST_MOD_CHECK = true;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
|
|||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
# In Windows, build-name is used as the major, minor, and patch parts
|
||||
# of the product and file versions while build-number is used as the build suffix.
|
||||
version: 1.1.010425+1723
|
||||
version: 1.1.010425+1748
|
||||
|
||||
environment:
|
||||
sdk: ">=3.1.4 <4.0.0"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue