it just works
This commit is contained in:
@@ -74,9 +74,12 @@ export default function Home({ socket }: Props) {
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
const interval = setInterval(() => client.running(), 1000)
|
||||
return () => clearInterval(interval)
|
||||
}, [])
|
||||
if (status.connected) {
|
||||
client.running()
|
||||
const interval = setInterval(() => client.running(), 1000)
|
||||
return () => clearInterval(interval)
|
||||
}
|
||||
}, [status.connected])
|
||||
|
||||
useEffect(() => {
|
||||
client.freeSpace()
|
||||
@@ -89,7 +92,7 @@ export default function Home({ socket }: Props) {
|
||||
switch (typeof res.result) {
|
||||
case 'object':
|
||||
setActiveDownloads(
|
||||
res.result
|
||||
(res.result ?? [])
|
||||
.filter((r: RPCResult) => !!r.info.url)
|
||||
.sort((a: RPCResult, b: RPCResult) => a.info.title.localeCompare(b.info.title))
|
||||
)
|
||||
|
||||
1
frontend/src/types.d.ts
vendored
1
frontend/src/types.d.ts
vendored
@@ -1,6 +1,7 @@
|
||||
export type RPCMethods =
|
||||
| "Service.Exec"
|
||||
| "Service.Kill"
|
||||
| "Service.Clear"
|
||||
| "Service.Running"
|
||||
| "Service.KillAll"
|
||||
| "Service.FreeSpace"
|
||||
|
||||
@@ -167,6 +167,7 @@ func (p *Process) Complete() {
|
||||
|
||||
// Kill a process and remove it from the memory
|
||||
func (p *Process) Kill() error {
|
||||
p.mem.Delete(p.id)
|
||||
// yt-dlp uses multiple child process the parent process
|
||||
// has been spawned with setPgid = true. To properly kill
|
||||
// all subprocesses a SIGTERM need to be sent to the correct
|
||||
@@ -176,8 +177,8 @@ func (p *Process) Kill() error {
|
||||
return err
|
||||
}
|
||||
err = syscall.Kill(-pgid, syscall.SIGTERM)
|
||||
p.mem.Delete(p.id)
|
||||
log.Printf("Killed process %s\n", p.id)
|
||||
|
||||
log.Println("Killed process", p.id)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -90,6 +90,13 @@ func (t *Service) KillAll(args NoArgs, killed *string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Remove a process from the db rendering it unusable if active
|
||||
func (t *Service) Clear(args string, killed *string) error {
|
||||
log.Println("Clearing process with id", args)
|
||||
db.Delete(args)
|
||||
return nil
|
||||
}
|
||||
|
||||
// FreeSpace gets the available from package sys util
|
||||
func (t *Service) FreeSpace(args NoArgs, free *uint64) error {
|
||||
freeSpace, err := sys.FreeSpace()
|
||||
|
||||
Reference in New Issue
Block a user