mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 13:36:09 +05:00
disable hibernate on open torrents
This commit is contained in:
@@ -6,6 +6,9 @@ package main
|
|||||||
import (
|
import (
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"server/torr"
|
||||||
|
"server/torr/state"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -16,6 +19,7 @@ const (
|
|||||||
var pulseTime = 1 * time.Minute
|
var pulseTime = 1 * time.Minute
|
||||||
|
|
||||||
func Preconfig(kill bool) {
|
func Preconfig(kill bool) {
|
||||||
|
go func() {
|
||||||
// don't sleep/hibernate windows
|
// don't sleep/hibernate windows
|
||||||
kernel32 := syscall.NewLazyDLL("kernel32.dll")
|
kernel32 := syscall.NewLazyDLL("kernel32.dll")
|
||||||
setThreadExecStateProc := kernel32.NewProc("SetThreadExecutionState")
|
setThreadExecStateProc := kernel32.NewProc("SetThreadExecutionState")
|
||||||
@@ -23,7 +27,19 @@ func Preconfig(kill bool) {
|
|||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-pulse.C:
|
case <-pulse.C:
|
||||||
|
{
|
||||||
|
send := false
|
||||||
|
for i, torrent := range torr.ListTorrent() {
|
||||||
|
if torrent.Stat != state.TorrentInDB {
|
||||||
|
send = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if send {
|
||||||
setThreadExecStateProc.Call(uintptr(EsSystemRequired))
|
setThreadExecStateProc.Call(uintptr(EsSystemRequired))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user