Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
B
bn_repos
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
package
bn_repos
Commits
0e5c2c80
Commit
0e5c2c80
authored
Apr 25, 2016
by
Thorsten Buss
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FIX: remove slash, cause with S3 ver3 SDK, there were removed the first letter of the dir
parent
1920fb23
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
2 deletions
+47
-2
AdapterAmazonS3Ver2.php
src/BNRepo/Repository/Adapter/AdapterAmazonS3Ver2.php
+2
-2
RepositoryS3Test.php
tests/BNRepo/Tests/Repository/RepositoryS3Test.php
+36
-0
RepositoryTest.php
tests/BNRepo/Tests/Repository/RepositoryTest.php
+9
-0
No files found.
src/BNRepo/Repository/Adapter/AdapterAmazonS3Ver2.php
View file @
0e5c2c80
...
...
@@ -202,7 +202,7 @@ class AdapterAmazonS3Ver2 extends AmazonS3 implements GaufretteAdapter, UrlAware
$this
->
ensureBucketExists
();
// add slash to beginning and remove from end
$prefix
=
rtrim
(
preg_replace
(
'/^[\/]*([^\/].*)[\/]?$/'
,
'
/
$1'
,
$prefix
),
'/'
);
$prefix
=
rtrim
(
preg_replace
(
'/^[\/]*([^\/].*)[\/]?$/'
,
'$1'
,
$prefix
),
'/'
);
return
$this
->
service
->
getIterator
(
'ListObjects'
,
array
(
'Bucket'
=>
$this
->
bucket
,
...
...
@@ -225,7 +225,7 @@ class AdapterAmazonS3Ver2 extends AmazonS3 implements GaufretteAdapter, UrlAware
$keys
=
array
();
$paths
=
array
();
$prefix_dir
=
rtrim
(
substr
(
$prefix
,
-
1
)
!=
'/'
?
dirname
(
$prefix
)
:
$prefix
,
'/'
);
$dirLength
=
strlen
(
$this
->
getDirectory
()
.
$prefix_dir
)
+
1
;
//+1 to
remove the starting slash
$dirLength
=
ltrim
(
strlen
(
$this
->
getDirectory
()
.
$prefix_dir
),
'/'
);
//
remove the starting slash
foreach
(
$iterator
as
$item
)
{
$file
=
substr
(
$item
[
'Key'
],
$dirLength
);
if
(
!
$file
)
continue
;
...
...
tests/BNRepo/Tests/Repository/RepositoryS3Test.php
0 → 100644
View file @
0e5c2c80
<?php
/**
* User: thorsten
* Date: 09.11.15
* Time: 10:28
*/
namespace
BNRepo\Tests\Repository
;
use
BNRepo\Repository\RepositoryManager
;
use
Symfony\Component\Yaml\Yaml
;
class
RepositoryS3Test
extends
\PHPUnit_Framework_TestCase
{
function
__construct
()
{
RepositoryManager
::
reset
();
$yml_file
=
__DIR__
.
'/../../../../../tibidono/app/config/repositories.yml'
;
RepositoryManager
::
importRepositoriesFromYamlFile
(
$yml_file
);
$this
->
cfg
=
Yaml
::
parse
(
$yml_file
);
}
public
function
testDirectoryList
()
{
$repo
=
RepositoryManager
::
getRepository
(
'tibidono-public'
);
print_r
(
$repo
->
keys
(
'/shop_uploads/'
));
print_r
(
$repo
->
keys
(
'/shop_voucher_body/756/'
));
}
public
function
testDirectoryList2
()
{
$repo
=
RepositoryManager
::
getRepository
(
'bnrepo-test-local'
);
print_r
(
$repo
->
keys
(
'/shop_uploads/'
));
}
}
tests/BNRepo/Tests/Repository/RepositoryTest.php
View file @
0e5c2c80
...
...
@@ -230,6 +230,15 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase {
sort
(
$ls
);
$this
->
assertEquals
(
$fileListWithPrefix
,
$ls
,
'directory structure with prefix correct [bothSlashes]'
);
// Check Prefix (show SubdirPrefix)
$fileListWithPrefix
=
array
(
'testFile1.txt'
,
);
$ls
=
$repo
->
keys
(
'/subdir/subsubdir/'
,
false
);
sort
(
$ls
);
$this
->
assertEquals
(
$fileListWithPrefix
,
$ls
,
'directory structure with deep prefix correct'
);
}
protected
function
_testCorrectFileStructureWithDirectories
(
Repository
$repo
)
{
$this
->
assertEquals
(
array
(),
$repo
->
keys
(),
'directory structure empty'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment