Skip to content

Commit 74929fd

Browse files
author
itismadness
committed
Add 'hasFiles()' method for Gazelle upload check
1 parent 5c26a5c commit 74929fd

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/BencodeTorrent.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,10 @@ function ($a, $b) {
449449
return $files;
450450
}
451451

452+
public function hasFiles(): bool {
453+
return isset($this->data['info']['files']);
454+
}
455+
452456
/**
453457
* Returns an array of strings formatted to be inserted into a Gazelle database into the table
454458
* torrents.FileList which is then used for displaying the table of files to the user when

tests/BencodeTorrentTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ public function testSetValue() {
310310
['.mp3 s1234s 01 Test??.mp3 ÷', '.mp3 s2345s 03 Test.mp3 ÷'],
311311
$bencode->getGazelleFileList()
312312
);
313+
$this->assertTrue($bencode->hasFiles());
313314
}
314315

315316
public function testGetUtf8Name() {
@@ -340,6 +341,7 @@ public function testIso88591Name() {
340341
$bencode = new BencodeTorrent();
341342
$bencode->setData($data);
342343
$this->assertEquals(['.,!?)óÉ s1234s (test.,!?)óÉ ÷'], $bencode->getGazelleFileList());
344+
$this->assertFalse($bencode->hasFiles());
343345
}
344346

345347
/**

0 commit comments

Comments
 (0)