Skip to content

Commit

Permalink
Some minor refactoring (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitpokhrel committed Jan 15, 2019
1 parent c049008 commit caf4da8
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/Cache/FileStore.php
Expand Up @@ -216,7 +216,7 @@ public function keys() : array
$contents = $this->getCacheContents();

if (is_array($contents)) {
return array_keys($this->getCacheContents());
return array_keys($contents);
}

return [];
Expand Down
4 changes: 3 additions & 1 deletion src/Commands/ExpirationCommand.php
Expand Up @@ -55,7 +55,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
Config::set($config);
}

$this->server = new TusServer(CacheFactory::make($input->getArgument('cache-adapter')));
$cacheAdapter = $input->getArgument('cache-adapter') ?? 'file';

$this->server = new TusServer(CacheFactory::make($cacheAdapter));

$deleted = $this->server->handleExpiration();

Expand Down
4 changes: 2 additions & 2 deletions src/Request.php
Expand Up @@ -70,8 +70,8 @@ public function allowedHttpVerbs() : array
/**
* Retrieve a header from the request.
*
* @param string $key
* @param string|array|null $default
* @param string $key
* @param string|string[]|null $default
*
* @return string|null
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Tus/Server.php
Expand Up @@ -420,12 +420,12 @@ protected function handleConcatenation(string $fileName, string $filePath) : Htt

// Verify checksum.
$checksum = $this->getServerChecksum($filePath);
$file->setChecksum($checksum);

if ($checksum !== $this->getClientChecksum()) {
return $this->response->send(null, self::HTTP_CHECKSUM_MISMATCH);
}

$file->setChecksum($checksum);
$this->cache->set($uploadKey, $file->details() + ['upload_type' => self::UPLOAD_TYPE_FINAL]);

// Cleanup.
Expand Down
6 changes: 0 additions & 6 deletions tests/Tus/ServerTest.php
Expand Up @@ -1350,12 +1350,6 @@ public function it_throws_460_for_checksum_mismatch_in_concatenation_request()
->once()
->with($key)
->andReturnSelf();

$fileMock
->shouldReceive('setChecksum')
->once()
->with($checksum)
->andReturnSelf();

$response = $this->tusServerMock->handleConcatenation($fileName, $filePath . $fileName);

Expand Down

0 comments on commit caf4da8

Please sign in to comment.