Skip to content

Commit f5d9c21

Browse files
committed
Don't same file twice from different seeders
1 parent ef4d0a5 commit f5d9c21

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/backend/swarm.cjs

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const PING_SYNC = 'Ping';
2424
let localFiles = []
2525
let remoteFiles = []
2626
let active_swarms = []
27+
let downloading = []
2728
let active_voice_channel = LOCAL_VOICE_STATUS_OFFLINE
2829

2930
async function send_voice_channel_sdp(data) {
@@ -564,6 +565,7 @@ const request_file = async (address, topic, file, room) => {
564565
console.log("-----------------------------")
565566
console.log("*** WANT TO REQUEST FILE ***")
566567
console.log("-----------------------------")
568+
downloading.push(file.hash)
567569
const verify = await verifySignature(file.hash + file.size.toString() + file.time.toString() + file.fileName, file.address, file.signature)
568570
if (!verify) return
569571
const key = randomKey()
@@ -586,6 +588,7 @@ const process_files = async (data, active, con, topic) => {
586588
for (const file of data.files) {
587589
console.log("File", file.fileName)
588590
if (!check_hash(file.hash)) continue
591+
if (downloading.some(a => a === file.hash)) continue
589592
if (Hugin.get_files().some(a => a.time === file.time)) continue
590593
await sleep(50)
591594
request_file(con.address, topic, file, active.key)

0 commit comments

Comments
 (0)