Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Nextcloud
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Nextcloud
Commits
e7f03486
Unverified
Commit
e7f03486
authored
4 years ago
by
Roeland Jago Douma
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #22651 from nextcloud/fix/s3/empty_files
Fix reading empty files from objectstorage
parents
c104c192
bb06b6cc
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
apps/files_external/lib/Lib/Storage/AmazonS3.php
+8
-2
8 additions, 2 deletions
apps/files_external/lib/Lib/Storage/AmazonS3.php
lib/private/Files/ObjectStore/ObjectStoreStorage.php
+5
-0
5 additions, 0 deletions
lib/private/Files/ObjectStore/ObjectStoreStorage.php
with
13 additions
and
2 deletions
apps/files_external/lib/Lib/Storage/AmazonS3.php
+
8
−
2
View file @
e7f03486
...
...
@@ -405,12 +405,12 @@ class AmazonS3 extends \OC\Files\Storage\Common {
*/
private
function
getContentLength
(
$path
)
{
if
(
isset
(
$this
->
filesCache
[
$path
]))
{
return
$this
->
filesCache
[
$path
][
'ContentLength'
];
return
(
int
)
$this
->
filesCache
[
$path
][
'ContentLength'
];
}
$result
=
$this
->
headObject
(
$path
);
if
(
isset
(
$result
[
'ContentLength'
]))
{
return
$result
[
'ContentLength'
];
return
(
int
)
$result
[
'ContentLength'
];
}
return
0
;
...
...
@@ -507,6 +507,12 @@ class AmazonS3 extends \OC\Files\Storage\Common {
switch
(
$mode
)
{
case
'r'
:
case
'rb'
:
// Don't try to fetch empty files
$stat
=
$this
->
stat
(
$path
);
if
(
is_array
(
$stat
)
&&
isset
(
$stat
[
'size'
])
&&
$stat
[
'size'
]
===
0
)
{
return
fopen
(
'php://memory'
,
$mode
);
}
try
{
return
$this
->
readObject
(
$path
);
}
catch
(
S3Exception
$e
)
{
...
...
This diff is collapsed.
Click to expand it.
lib/private/Files/ObjectStore/ObjectStoreStorage.php
+
5
−
0
View file @
e7f03486
...
...
@@ -296,6 +296,11 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common {
case
'rb'
:
$stat
=
$this
->
stat
(
$path
);
if
(
is_array
(
$stat
))
{
// Reading 0 sized files is a waste of time
if
(
isset
(
$stat
[
'size'
])
&&
$stat
[
'size'
]
===
0
)
{
return
fopen
(
'php://memory'
,
$mode
);
}
try
{
return
$this
->
objectStore
->
readObject
(
$this
->
getURN
(
$stat
[
'fileid'
]));
}
catch
(
NotFoundException
$e
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment