Skip to content
This repository was archived by the owner on Jun 14, 2021. It is now read-only.

Commit e0d2c25

Browse files
author
XiaoLin
committed
fix: interval not set
1 parent b223ff5 commit e0d2c25

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/handle/init.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ const runAndSetInterval = async (fn, time) => {
1515
logger.error(`[Check torrent status] Job threw an error`, error)
1616
}
1717
logger.info(`[Check torrent status] Job finished, setting timer`)
18-
setTimeout(fn, time * 1000)
18+
19+
setTimeout(() => {
20+
runAndSetInterval(fn, time)
21+
}, time * 1000)
1922
}
2023

2124
const process = async () => {

src/pull/init.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ const runAndSetInterval = async (fn, time, name, handle = true) => {
2727
logger.error(`[${name}] Job threw an error`, error)
2828
}
2929
logger.info(`[${name}] Job finished, setting timer`)
30-
setTimeout(fn, time * 1000)
30+
31+
setTimeout(() => {
32+
runAndSetInterval(fn, time, name, handle)
33+
}, time * 1000)
3134
}
3235

3336
const contentHandler = async () => {
@@ -50,6 +53,8 @@ const contentHandler = async () => {
5053
const size = item.size
5154
const hash = item.hash
5255

56+
logger.info(`Handling ${JAVID}, hash ${hash}`)
57+
5358
if (size > 10) {
5459
logger.info(`[${JAVID}] File oversize, skipped`)
5560
continue
@@ -101,6 +106,7 @@ const contentHandler = async () => {
101106
})
102107
}
103108

109+
logger.debug(`[${JAVID}] Parsing torrent info`)
104110
const torrentInfo = parseTorrent(fs.readFileSync(torrentFilePath))
105111
if (!torrentInfo.files) {
106112
logger.warn(`[${JAVID}] Torrent invalid, skipped`)
@@ -109,6 +115,7 @@ const contentHandler = async () => {
109115

110116
let videoFileCount = 0
111117

118+
logger.debug(`[${JAVID}] Torrent files`, torrentInfo.files)
112119
for (const index in torrentInfo.files) {
113120
const fileInfo = torrentInfo.files[index]
114121

@@ -122,6 +129,7 @@ const contentHandler = async () => {
122129
continue
123130
}
124131

132+
logger.debug(`[${JAVID}] Adding to qbittorrent`)
125133
await qb.addTorrentLink(torrentURL)
126134

127135
db.get('processed').push({

0 commit comments

Comments
 (0)