mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-15 08:34:43 +01:00
test download and remove files
This commit is contained in:
BIN
grassclipper.zip
BIN
grassclipper.zip
Binary file not shown.
@@ -18,12 +18,20 @@ async function download(url: string, filename: string, path: string) {
|
|||||||
downloadHandler.addDownload(url, completePath)
|
downloadHandler.addDownload(url, completePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function TESTDOWNLOAD() {
|
||||||
|
download(
|
||||||
|
'https://github.com/Grasscutters/Grasscutter/archive/refs/heads/stable.zip',
|
||||||
|
'grasscutter.zip',
|
||||||
|
'S:/Cultivation'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
return (
|
return (
|
||||||
<div className="App">
|
<div className="App">
|
||||||
<Topbar />
|
<Topbar />
|
||||||
|
|
||||||
<button>download file test</button>
|
<button onClick={TESTDOWNLOAD}>download file test</button>
|
||||||
|
|
||||||
<ServerLaunchSection />
|
<ServerLaunchSection />
|
||||||
|
|
||||||
|
|||||||
@@ -37,9 +37,7 @@ export default class ProgressBar extends React.Component<IProps, IState> {
|
|||||||
total: prog?.total || 0,
|
total: prog?.total || 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
if (this.state.files === 0 /* || this.state.status === 'error' */) {
|
console.log(prog)
|
||||||
clearInterval(intv)
|
|
||||||
}
|
|
||||||
}, 500)
|
}, 500)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ export default class DownloadHandler {
|
|||||||
const progress = files.reduce((acc, d) => acc + d.progress, 0)
|
const progress = files.reduce((acc, d) => acc + d.progress, 0)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
average: (progress / total) * 100,
|
average: (progress / total) * 100 || 0,
|
||||||
files: this.downloads.filter(d => d.status !== 'finished').length,
|
files: this.downloads.filter(d => d.status !== 'finished').length,
|
||||||
totalSize: total,
|
totalSize: total,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user