diff options
author | Jörn Friedrich Dreyer <jfd@butonic.de> | 2012-10-05 12:29:27 +0200 |
---|---|---|
committer | Jörn Friedrich Dreyer <jfd@butonic.de> | 2012-10-05 12:29:36 +0200 |
commit | 00b34a09eaeba2f74a44a155f0fdd4aa58d5e502 (patch) | |
tree | 25680ef588621ecc543a4dbd85b2509af8537f0f | |
parent | 72a48ca35eb99be1b3fae8bd9843dabcd7ff1a11 (diff) | |
download | nextcloud-server-00b34a09eaeba2f74a44a155f0fdd4aa58d5e502.tar.gz nextcloud-server-00b34a09eaeba2f74a44a155f0fdd4aa58d5e502.zip |
cache tar archive headers
-rw-r--r-- | lib/archive/tar.php | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/archive/tar.php b/lib/archive/tar.php index 639d2392b63..21d8057e4d6 100644 --- a/lib/archive/tar.php +++ b/lib/archive/tar.php @@ -14,6 +14,7 @@ class OC_Archive_TAR extends OC_Archive{ const BZIP=2; private $fileList; + private $cachedHeaders; /** * @var Archive_Tar tar @@ -74,6 +75,7 @@ class OC_Archive_TAR extends OC_Archive{ $result=$this->tar->addModify(array($tmpBase.$path), '', $tmpBase); rmdir($tmpBase.$path); $this->fileList=false; + $this->cachedHeaders=false; return $result; } /** @@ -95,6 +97,7 @@ class OC_Archive_TAR extends OC_Archive{ $result=$this->tar->addString($path, $source); } $this->fileList=false; + $this->cachedHeaders=false; return $result; } @@ -115,12 +118,15 @@ class OC_Archive_TAR extends OC_Archive{ $this->tar=new Archive_Tar($this->path, $types[self::getTarType($this->path)]); $this->tar->createModify(array($tmp), '', $tmp.'/'); $this->fileList=false; + $this->cachedHeaders=false; return true; } private function getHeader($file) { - $headers=$this->tar->listContent(); - foreach($headers as $header) { + if ( ! $this->cachedHeaders ) { + $this->cachedHeaders = $this->tar->listContent(); + } + foreach($this->cachedHeaders as $header) { if($file==$header['filename'] or $file.'/'==$header['filename'] or '/'.$file.'/'==$header['filename'] or '/'.$file==$header['filename']) { return $header; } @@ -180,9 +186,11 @@ class OC_Archive_TAR extends OC_Archive{ if($this->fileList) { return $this->fileList; } - $headers=$this->tar->listContent(); + if ( ! $this->cachedHeaders ) { + $this->cachedHeaders = $this->tar->listContent(); + } $files=array(); - foreach($headers as $header) { + foreach($this->cachedHeaders as $header) { $files[]=$header['filename']; } $this->fileList=$files; @@ -265,6 +273,7 @@ class OC_Archive_TAR extends OC_Archive{ return false; } $this->fileList=false; + $this->cachedHeaders=false; //no proper way to delete, extract entire archive, delete file and remake archive $tmp=OCP\Files::tmpFolder(); $this->tar->extract($tmp); |