Skip to content

Commit

Permalink
Add 'hasFiles()' method for Gazelle upload check
Browse files Browse the repository at this point in the history
  • Loading branch information
itismadness committed Apr 11, 2018
1 parent 5c26a5c commit 74929fd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/BencodeTorrent.php
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,10 @@ function ($a, $b) {
return $files;
}

public function hasFiles(): bool {
return isset($this->data['info']['files']);
}

/**
* Returns an array of strings formatted to be inserted into a Gazelle database into the table
* torrents.FileList which is then used for displaying the table of files to the user when
Expand Down
2 changes: 2 additions & 0 deletions tests/BencodeTorrentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ public function testSetValue() {
['.mp3 s1234s 01 Test??.mp3 ÷', '.mp3 s2345s 03 Test.mp3 ÷'],
$bencode->getGazelleFileList()
);
$this->assertTrue($bencode->hasFiles());
}

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

/**
Expand Down

0 comments on commit 74929fd

Please sign in to comment.