Skip to content

Commit ae47962

Browse files
Merge pull request #265 from wowkaster/
B2 sync fix bug
2 parents 51fd7f9 + 3385c32 commit ae47962

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

src/Backup/Sync/BackblazeS3.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*/
2020
class BackblazeS3 extends AmazonS3v3
2121
{
22+
2223
/**
2324
* Create the Backblaze AWS client.
2425
*
@@ -44,8 +45,8 @@ protected function createClient() : S3Client
4445
*
4546
* @return string
4647
*/
47-
private function createEndpoint()
48+
protected function createEndpoint()
4849
{
49-
return strtr('https://s3.{region}.backblazeb2.com', '{region}', $this->region);
50+
return str_replace('{region}', $this->region, 'https://s3.{region}.backblazeb2.com');
5051
}
5152
}

tests/phpbu/Backup/Sync/BackblazeS3Test.php

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ class BackblazeS3Test extends TestCase
2424
*/
2525
public function testSetUpOk()
2626
{
27-
$amazonS3 = new BackblazeS3();
28-
$amazonS3->setup([
27+
$b2 = new BackblazeS3();
28+
$b2->setup([
2929
'key' => 'dummy-key',
3030
'secret' => 'dummy-secret',
3131
'bucket' => 'dummy-bucket',
@@ -36,4 +36,23 @@ public function testSetUpOk()
3636
$this->assertTrue(true, 'no exception should occur');
3737
}
3838

39-
}
39+
public function testEndpoint()
40+
{
41+
$b2 = new BackblazeS3();
42+
$b2->setup([
43+
'key' => 'dummy-key',
44+
'secret' => 'dummy-secret',
45+
'bucket' => 'dummy-bucket',
46+
'region' => 'dummy-region',
47+
'path' => '/'
48+
]);
49+
50+
$createEndpointPrivateMethod = function () {
51+
return $this->createEndpoint();
52+
};
53+
54+
$createEndpointClosure = $createEndpointPrivateMethod->bindTo($b2, $b2);
55+
56+
$this->assertEquals($createEndpointClosure(), 'https://s3.dummy-region.backblazeb2.com');
57+
}
58+
}

0 commit comments

Comments
 (0)