use temporary file managment
This commit is contained in:
parent
a76ff563d6
commit
3e0bb3e7c4
|
@ -92,7 +92,8 @@ abstract class OC_Filestorage_Common extends OC_Filestorage {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$head=fread($source,8192);//8kb should suffice to determine a mimetype
|
$head=fread($source,8192);//8kb should suffice to determine a mimetype
|
||||||
$tmpFile=tempnam(get_temp_dir(),'OC_TMP_').substr($path,strrpos($path,'.'));
|
$extention=substr($path,strrpos($path,'.'));
|
||||||
|
$tmpFile=OC_Helper::tmpFile($extention);
|
||||||
file_put_contents($tmpFile,$head);
|
file_put_contents($tmpFile,$head);
|
||||||
$mime=OC_Helper::getMimeType($tmpFile);
|
$mime=OC_Helper::getMimeType($tmpFile);
|
||||||
unlink($tmpFile);
|
unlink($tmpFile);
|
||||||
|
@ -114,7 +115,8 @@ abstract class OC_Filestorage_Common extends OC_Filestorage {
|
||||||
if(!$source){
|
if(!$source){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$tmpFile=tempnam(get_temp_dir(),'OC_TMP_').substr($path,strrpos($path,'.'));
|
$extention=substr($path,strrpos($path,'.'));
|
||||||
|
$tmpFile=OC_Helper::tmpFile($extention);
|
||||||
$target=fopen($tmpFile);
|
$target=fopen($tmpFile);
|
||||||
$count=OC_Helper::streamCopy($source,$target);
|
$count=OC_Helper::streamCopy($source,$target);
|
||||||
return $tmpFile;
|
return $tmpFile;
|
||||||
|
|
|
@ -278,8 +278,9 @@ class OC_FilesystemView {
|
||||||
public function toTmpFile($path){
|
public function toTmpFile($path){
|
||||||
if(OC_Filesystem::isValidPath($path)){
|
if(OC_Filesystem::isValidPath($path)){
|
||||||
$source=$this->fopen($path,'r');
|
$source=$this->fopen($path,'r');
|
||||||
$tmpFile=tempnam(get_temp_dir(),'OC_TMP_').substr($path,strrpos($path,'.'));
|
|
||||||
if($source){
|
if($source){
|
||||||
|
$extention=substr($path,strrpos($path,'.'));
|
||||||
|
$tmpFile=OC_Helper::tmpFile($extention);
|
||||||
return file_put_contents($tmpFile,$source);
|
return file_put_contents($tmpFile,$source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ class OC_Installer{
|
||||||
|
|
||||||
//download the file if necesary
|
//download the file if necesary
|
||||||
if($data['source']=='http'){
|
if($data['source']=='http'){
|
||||||
$path=tempnam(get_temp_dir(),'oc_installer_');
|
$path=OC_Helper::tmpFile('.zip');
|
||||||
if(!isset($data['href'])){
|
if(!isset($data['href'])){
|
||||||
OC_Log::write('core','No href specified when installing app from http',OC_Log::ERROR);
|
OC_Log::write('core','No href specified when installing app from http',OC_Log::ERROR);
|
||||||
return false;
|
return false;
|
||||||
|
@ -142,9 +142,6 @@ class OC_Installer{
|
||||||
|
|
||||||
//remove temporary files
|
//remove temporary files
|
||||||
OC_Helper::rmdirr($extractDir);
|
OC_Helper::rmdirr($extractDir);
|
||||||
if($data['source']=='http'){
|
|
||||||
unlink($path);
|
|
||||||
}
|
|
||||||
|
|
||||||
//install the database
|
//install the database
|
||||||
if(is_file($basedir.'/appinfo/database.xml')){
|
if(is_file($basedir.'/appinfo/database.xml')){
|
||||||
|
|
Loading…
Reference in New Issue