Skip to content

Commit

Permalink
Bug fixes (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
mlambley authored Feb 5, 2021
1 parent 8aebde2 commit 568b951
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
1 change: 0 additions & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="true"
verbose="true"
>
<testsuites>
Expand Down
11 changes: 7 additions & 4 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ public function download(array $options)
*
* @throws B2Exception
* @throws GuzzleException
* @throws InvalidArgumentException
* @throws NotFoundException
*
* @return File
*/
Expand All @@ -301,10 +301,13 @@ public function copy(array $options)
$options['BucketId'] = $this->getBucketIdFromName($options['BucketName']);
}

$sourceFiles = $this->listFiles($options['BucketId'], $options['FileName']);
$sourceFiles = $this->listFiles([
'BucketId' => $options['BucketId'],
'FileName' => $options['FileName'],
]);
$sourceFileId = !empty($sourceFiles) ? $sourceFiles[0]->getId() : false;
if (!$sourceFileId) {
throw new InvalidArgumentException('Source file not found in B2');
throw new NotFoundException('Source file not found in B2');
}

$json = [
Expand All @@ -326,7 +329,7 @@ public function copy(array $options)
$response['fileInfo'],
$response['bucketId'],
$response['action'],
$response['uploadTimestamp'],
$response['uploadTimestamp']
);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/responses/list_files_page1.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"action": "upload",
"fileId": "4_z4c2b957661hy9c825f260e1b_f115af4dca081b246_d20160131_m160446_f001_v0011017_t0002",
"fileName": "testfile.bin",
"fileName": "sourceFileName",
"size": 140827,
"uploadTimestamp": 1454256286000
},
Expand Down

0 comments on commit 568b951

Please sign in to comment.