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
99ad4e80
Commit
99ad4e80
authored
11 years ago
by
Nicolai Ehemann
Browse files
Options
Downloads
Patches
Plain Diff
switched zip file creation to ZipStreamer to create zip files directly in memory
parent
791772ab
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/private/files.php
+9
-33
9 additions, 33 deletions
lib/private/files.php
with
9 additions
and
33 deletions
lib/private/files.php
+
9
−
33
View file @
99ad4e80
...
...
@@ -20,6 +20,7 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
require_once
(
'ZipStreamer/ZipStreamer.php'
);
class
GET_TYPE
{
const
FILE
=
1
;
...
...
@@ -32,8 +33,6 @@ class GET_TYPE {
*
*/
class
OC_Files
{
static
$tmpFiles
=
array
();
static
public
function
getFileInfo
(
$path
,
$includeMountPoints
=
true
){
return
\OC\Files\Filesystem
::
getFileInfo
(
$path
,
$includeMountPoints
);
}
...
...
@@ -103,12 +102,7 @@ class OC_Files {
}
}
else
{
self
::
validateZipDownload
(
$dir
,
$files
);
$zip
=
new
ZipArchive
();
$filename
=
OC_Helper
::
tmpFile
(
'.zip'
);
if
(
$zip
->
open
(
$filename
,
ZIPARCHIVE
::
CREATE
|
ZIPARCHIVE
::
OVERWRITE
)
!==
true
)
{
$l
=
OC_L10N
::
get
(
'lib'
);
throw
new
Exception
(
$l
->
t
(
'cannot open "%s"'
,
array
(
$filename
)));
}
$zip
=
new
ZipStreamer
(
false
);
}
OC_Util
::
obEnd
();
if
(
$zip
or
\OC\Files\Filesystem
::
isReadable
(
$filename
))
{
...
...
@@ -132,9 +126,9 @@ class OC_Files {
foreach
(
$files
as
$file
)
{
$file
=
$dir
.
'/'
.
$file
;
if
(
\OC\Files\Filesystem
::
is_file
(
$file
))
{
$
tmpFile
=
\OC\Files\Filesystem
::
toTmpFile
(
$file
);
self
::
$tmpFiles
[]
=
$tmpF
ile
;
$zip
->
addFile
(
$tmpFile
,
basename
(
$file
)
);
$
fh
=
\OC\Files\Filesystem
::
fopen
(
$file
,
'r'
);
$zip
->
addFileFromStream
(
$fh
,
basename
(
$f
ile
))
;
fclose
(
$fh
);
}
elseif
(
\OC\Files\Filesystem
::
is_dir
(
$file
))
{
self
::
zipAddDir
(
$file
,
$zip
);
}
...
...
@@ -143,20 +137,7 @@ class OC_Files {
$file
=
$dir
.
'/'
.
$files
;
self
::
zipAddDir
(
$file
,
$zip
);
}
$zip
->
close
();
if
(
$xsendfile
)
{
$filename
=
OC_Helper
::
moveToNoClean
(
$filename
);
self
::
addSendfileHeader
(
$filename
);
}
else
{
$handle
=
fopen
(
$filename
,
'r'
);
if
(
$handle
)
{
$chunkSize
=
8
*
1024
;
// 1 MB chunks
while
(
!
feof
(
$handle
))
{
echo
fread
(
$handle
,
$chunkSize
);
flush
();
}
}
}
$zip
->
finalize
();
set_time_limit
(
$executionTime
);
}
else
{
if
(
$xsendfile
)
{
...
...
@@ -170,11 +151,6 @@ class OC_Files {
\OC\Files\Filesystem
::
readfile
(
$filename
);
}
}
foreach
(
self
::
$tmpFiles
as
$tmpFile
)
{
if
(
file_exists
(
$tmpFile
)
and
is_file
(
$tmpFile
))
{
unlink
(
$tmpFile
);
}
}
}
private
static
function
addSendfileHeader
(
$filename
)
{
...
...
@@ -210,9 +186,9 @@ class OC_Files {
$filename
=
$file
[
'name'
];
$file
=
$dir
.
'/'
.
$filename
;
if
(
\OC\Files\Filesystem
::
is_file
(
$file
))
{
$
tmpFile
=
\OC\Files\Filesystem
::
toTmpFile
(
$file
);
OC_Files
::
$tmpFiles
[]
=
$tmpFile
;
$zip
->
addFile
(
$tmpFile
,
$internalDir
.
$filename
);
$
fh
=
\OC\Files\Filesystem
::
fopen
(
$file
,
'r'
);
$zip
->
addFileFromStream
(
$fh
,
$internalDir
.
$filename
)
;
fclose
(
$fh
);
}
elseif
(
\OC\Files\Filesystem
::
is_dir
(
$file
))
{
self
::
zipAddDir
(
$file
,
$zip
,
$internalDir
);
}
...
...
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