Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
9015c46e
Commit
9015c46e
authored
12 years ago
by
Robin Appelman
Browse files
Options
Downloads
Patches
Plain Diff
emit the correct hooks for file_put_contents and some readfile improvements
parent
60b924c9
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/filesystemview.php
+16
-3
16 additions, 3 deletions
lib/filesystemview.php
with
16 additions
and
3 deletions
lib/filesystemview.php
+
16
−
3
View file @
9015c46e
...
...
@@ -136,15 +136,16 @@ class OC_FilesystemView {
return
$this
->
basicOperation
(
'filesize'
,
$path
);
}
public
function
readfile
(
$path
){
@
ob_end_clean
();
$handle
=
$this
->
fopen
(
$path
,
'r'
);
if
(
$handle
)
{
$chunkSize
=
1024
*
1024
;
// 1 MB chunks
$chunkSize
=
8
*
1024
;
// 1 MB chunks
while
(
!
feof
(
$handle
))
{
echo
fread
(
$handle
,
$chunkSize
);
@
ob_flush
();
flush
();
}
return
$this
->
filesize
(
$path
);
$size
=
$this
->
filesize
(
$path
);
return
$size
;
}
return
false
;
}
...
...
@@ -174,11 +175,23 @@ class OC_FilesystemView {
}
public
function
file_put_contents
(
$path
,
$data
){
if
(
is_resource
(
$data
)){
//not having to deal with streams in file_put_contents makes life easier
$exists
=
$this
->
file_exists
(
$path
);
$run
=
true
;
if
(
!
$exists
){
OC_Hook
::
emit
(
OC_Filesystem
::
CLASSNAME
,
OC_Filesystem
::
signal_create
,
array
(
OC_Filesystem
::
signal_param_path
=>
$path
,
OC_Filesystem
::
signal_param_run
=>
&
$run
));
}
OC_Hook
::
emit
(
OC_Filesystem
::
CLASSNAME
,
OC_Filesystem
::
signal_write
,
array
(
OC_Filesystem
::
signal_param_path
=>
$path
,
OC_Filesystem
::
signal_param_run
=>
&
$run
));
if
(
!
$run
){
return
false
;
}
$target
=
$this
->
fopen
(
$path
,
'w'
);
if
(
$target
){
$count
=
OC_Helper
::
streamCopy
(
$data
,
$target
);
fclose
(
$target
);
fclose
(
$data
);
if
(
!
$exists
){
OC_Hook
::
emit
(
OC_Filesystem
::
CLASSNAME
,
OC_Filesystem
::
signal_post_create
,
array
(
OC_Filesystem
::
signal_param_path
=>
$path
));
}
OC_Hook
::
emit
(
OC_Filesystem
::
CLASSNAME
,
OC_Filesystem
::
signal_post_write
,
array
(
OC_Filesystem
::
signal_param_path
=>
$path
));
return
$count
>
0
;
}
else
{
...
...
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