Skip to content

Commit

Permalink
download ratelimit fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Rumrobot committed Jun 22, 2024
1 parent 21aa381 commit 4541032
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
10 changes: 4 additions & 6 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# Todo
## Fixes

## New features

- Cancel button for downloading
- map and mod filtering
- different languages

## QOL

- mbps counter
- fixed sorting and filtering tools in the server list
- Cancel button for downloading
- mbps counter
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"package": {
"productName": "Pavlov Map Manager",
"version": "1.3.0"
"version": "1.3.1"
},
"tauri": {
"allowlist": {
Expand Down
17 changes: 13 additions & 4 deletions src/lib/modio-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export async function loadMods() {
app.status = "Assigning data";
appStore.set(app);

const allMods = new Set([ ...subscriptions.map(sub => sub.id), ...localMods]);
const allMods = new Set([...subscriptions.map(sub => sub.id), ...localMods]);
const max = allMods.size;
let current = 1;

Expand Down Expand Up @@ -181,15 +181,24 @@ async function downloadMap(mod: string) {
headers.set("Accept", "application/json");
headers.set("X-Modio-Platform", "windows");

let recSize = 0;
let updateCounter = 0;
let lastUpdate = 0;

await download(
fileInfo.download.binary_url,
`${mod}.zip`,
(progress, total) => {
app.receivedSize += progress;
appStore.set(app);
recSize += progress;
updateCounter++;
if (updateCounter - lastUpdate > 200) {
appStore.update((store) => ({ ...store, receivedSize: recSize }));
lastUpdate = updateCounter;
}
},
headers
);
//console.log("Took ", updateCounter, " updates to download the file");
} catch (error) {
toast.error("Error while downloading file");
console.log("Error while downloading file: ", error);
Expand All @@ -201,7 +210,7 @@ async function downloadMap(mod: string) {

// Check MD5 hash of the file
const hash = await invoke("md5", { filePath: `${mod}.zip` });

if (hash != fileInfo.filehash.md5) {
console.log("MD5 hash does not match for map: ", mods[mod].title);
toast.error(mods[mod].title + " didn't download correctly");
Expand Down

0 comments on commit 4541032

Please sign in to comment.