Skip to content

Commit

Permalink
send progress message as soon as database is done loading, don't send…
Browse files Browse the repository at this point in the history
… all worker requests at once, fix logging empty error array, use graceful-fs instead of fs
  • Loading branch information
Yentis committed Nov 25, 2021
1 parent 4b74b5a commit b86bc5c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "osu-local-scores",
"version": "1.0.1",
"version": "1.0.2",
"description": "Process local replays and present them in a filterable way",
"productName": "osu! Score Overview",
"author": "Yentis#5218",
Expand All @@ -12,25 +12,25 @@
"build::wasm": "cd src-wasm && cargo clippy && wasm-pack build",
"build::electron": "quasar build -m electron"
},
"dependencies": {
"@quasar/extras": "^1.0.0",
"core-js": "^3.6.5",
"quasar": "^2.0.0"
},
"devDependencies": {
"@babel/eslint-parser": "^7.13.14",
"@quasar/app": "^3.0.0",
"@quasar/extras": "^1.0.0",
"@types/graceful-fs": "^4.1.5",
"@types/node": "^12.20.21",
"@typescript-eslint/eslint-plugin": "^4.16.1",
"@typescript-eslint/parser": "^4.16.1",
"core-js": "^3.6.5",
"electron": "^16.0.1",
"electron-packager": "^15.2.0",
"eslint": "^7.14.0",
"eslint-config-standard": "^16.0.2",
"eslint-plugin-import": "^2.19.1",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-promise": "^5.1.0",
"eslint-plugin-vue": "^7.0.0"
"eslint-plugin-vue": "^7.0.0",
"graceful-fs": "^4.2.8",
"quasar": "^2.0.0"
},
"browserslist": [
"last 10 Chrome versions",
Expand Down
2 changes: 1 addition & 1 deletion src-electron/electron-main.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { app, BrowserWindow, dialog, ipcMain, nativeTheme, OpenDialogReturnValue, protocol, ProtocolRequest, ProtocolResponse } from 'electron'
import path from 'path'
import os from 'os'
import fs, { FSWatcher } from 'fs'
import { FileBufferResult } from 'src/interfaces/ElectronWindow'
import fs, { FSWatcher } from 'graceful-fs'

// needed in case process is undefined under Linux
const platform = process.platform || os.platform()
Expand Down
9 changes: 5 additions & 4 deletions src/worker/Worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,15 +281,16 @@ const PP_CHUNK = 100
async function calculateAllPpValues (osuPath: string) {
if (!beatmaps) return
let i, j, temporary
const promises: Promise<void>[] = []
const beatmapList = Object.values(beatmaps)

const workerData: WorkerData = { id: 'pp-progress', func: WorkerFunc.BATCH_CALCULATE_PP, args: 0 }
postMessage(workerData)

for (i = 0, j = beatmapList.length; i < j; i += PP_CHUNK) {
temporary = beatmapList.slice(i, i + PP_CHUNK)
promises.push(calculatePpValues(osuPath, temporary))
await calculatePpValues(osuPath, temporary)
}

await Promise.all(promises)
calculatedCount = 0
}

Expand All @@ -313,7 +314,7 @@ async function calculatePpValues (osuPath: string, beatmaps: DatabaseResponse[])
}

const { buffers, errors } = await getFileBuffers(pathMap)
if (errors) console.error(errors)
if (errors.length > 0) console.error(errors)

batchCalculatePp(buffers)
}
Expand Down
9 changes: 8 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,13 @@
"@types/minimatch" "*"
"@types/node" "*"

"@types/graceful-fs@^4.1.5":
version "4.1.5"
resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.5.tgz#21ffba0d98da4350db64891f92a9e5db3cdb4e15"
integrity sha512-anKkLmZZ+xm4p8JWBf4hElkM4XR+EZeA2M9BAkkTldmcyDY4mbdIJnRghDJH3Ov5ooY7/UAoENtmdMSkaAd7Cw==
dependencies:
"@types/node" "*"

"@types/html-minifier-terser@^6.0.0":
version "6.0.0"
resolved "https://registry.yarnpkg.com/@types/html-minifier-terser/-/html-minifier-terser-6.0.0.tgz#563c1c6c132cd204e71512f9c0b394ff90d3fae7"
Expand Down Expand Up @@ -3866,7 +3873,7 @@ got@^9.6.0:
to-readable-stream "^1.0.0"
url-parse-lax "^3.0.0"

graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.4, graceful-fs@^4.2.6:
graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.4, graceful-fs@^4.2.6, graceful-fs@^4.2.8:
version "4.2.8"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.8.tgz#e412b8d33f5e006593cbd3cee6df9f2cebbe802a"
integrity sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg==
Expand Down

0 comments on commit b86bc5c

Please sign in to comment.