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 (
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"server/torr"
|
||||
"server/torr/state"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -16,6 +19,7 @@ const (
|
||||
var pulseTime = 1 * time.Minute
|
||||
|
||||
func Preconfig(kill bool) {
|
||||
go func() {
|
||||
// don't sleep/hibernate windows
|
||||
kernel32 := syscall.NewLazyDLL("kernel32.dll")
|
||||
setThreadExecStateProc := kernel32.NewProc("SetThreadExecutionState")
|
||||
@@ -23,7 +27,19 @@ func Preconfig(kill bool) {
|
||||
for {
|
||||
select {
|
||||
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))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user