Skip to content
This repository has been archived by the owner on Sep 10, 2021. It is now read-only.

Commit

Permalink
Fix zipped folder downloads
Browse files Browse the repository at this point in the history
Fixes #101.
  • Loading branch information
Jamie Snape committed Mar 27, 2015
1 parent 1e2f0e4 commit ed73c47
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
10 changes: 5 additions & 5 deletions core/controllers/DownloadController.php
Expand Up @@ -157,12 +157,12 @@ public function indexAction()
$name = $revision->getItem()->getName();
$name = substr($name, 0, 50);
session_write_close(); // unlock session writing for concurrent access
$zip = new ZipStream($name.'.zip');
$zip = new \ZipStream\ZipStream($name.'.zip');
foreach ($bitstreams as $bitstream) {
$filename = $bitstream->getName();
$path = $bitstream->getAssetstore()->getPath().'/'.$bitstream->getPath();
Zend_Registry::get('dbAdapter')->closeConnection();
$zip->add_file_from_path($filename, $path);
$zip->addFileFromPath($filename, $path);
}
$zip->finish();
$this->Item->incrementDownloadCount($revision->getItem());
Expand Down Expand Up @@ -191,7 +191,7 @@ public function indexAction()

session_write_close(); // unlock session writing for concurrent access
ob_start();
$zip = new ZipStream($name.'.zip');
$zip = new \ZipStream\ZipStream($name.'.zip');
UtilityComponent::disableMemoryLimit();
foreach ($revisions as $revision) {
$item = $revision->getItem();
Expand All @@ -208,7 +208,7 @@ public function indexAction()
$filename = $path.$bitstream->getName();
$fullpath = $bitstream->getAssetstore()->getPath().'/'.$bitstream->getPath();
Zend_Registry::get('dbAdapter')->closeConnection();
$zip->add_file_from_path($filename, $fullpath);
$zip->addFileFromPath($filename, $fullpath);
}
$this->Item->incrementDownloadCount($item);
unset($item);
Expand Down Expand Up @@ -363,7 +363,7 @@ private function _downloadEmptyItem($item)

return;
}
$zip = new ZipStream($name.'.zip');
$zip = new \ZipStream\ZipStream($name.'.zip');
$zip->finish();
exit();
}
Expand Down
4 changes: 2 additions & 2 deletions core/models/pdo/FolderModel.php
Expand Up @@ -1352,7 +1352,7 @@ public function zipStream(&$zip, $path, $folder, &$userDao, &$overrideOutputFunc
$rev = $this->Item->getLastRevision($item);

if (!$rev) {
$zip->add_file($path.'/'.$item->getName(), ''); // add empty item
$zip->addFile($path.'/'.$item->getName(), ''); // add empty item
continue;
}
$bitstreams = $rev->getBitstreams();
Expand All @@ -1370,7 +1370,7 @@ public function zipStream(&$zip, $path, $folder, &$userDao, &$overrideOutputFunc
} else {
$currPath = $path.'/'.$bitstream->getName();
}
$zip->add_file_from_path(
$zip->addFileFromPath(
$currPath,
$bitstream->getAssetstore()->getPath().'/'.$bitstream->getPath()
);
Expand Down
10 changes: 5 additions & 5 deletions modules/keyfiles/controllers/DownloadController.php
Expand Up @@ -52,10 +52,10 @@ public function itemAction()

$this->_emptyOutputBuffer();
ob_start(); //must start a new buffer for ZipStream to work
$zip = new ZipStream($item->getName().'.zip');
$zip = new \ZipStream\ZipStream($item->getName().'.zip');
$bitstreams = $revision->getBitstreams();
foreach ($bitstreams as $bitstream) {
$zip->add_file($bitstream->getName().'.md5', $bitstream->getChecksum());
$zip->addFile($bitstream->getName().'.md5', $bitstream->getChecksum());
}
$zip->finish();
exit();
Expand Down Expand Up @@ -138,7 +138,7 @@ public function batchAction()
}
$this->_emptyOutputBuffer();
ob_start(); //must start a new output buffer for ZipStream to work
$zip = new ZipStream('Keyfiles.zip');
$zip = new \ZipStream\ZipStream('Keyfiles.zip');
// Iterate over top level items
foreach ($items as $item) {
if (!$this->Item->policyCheck($item, $this->userSession->Dao)) {
Expand All @@ -160,7 +160,7 @@ public function batchAction()
}
$filename = $path.$bitstream->getName().'.md5';
Zend_Registry::get('dbAdapter')->closeConnection();
$zip->add_file($filename, $bitstream->getChecksum());
$zip->addFile($filename, $bitstream->getChecksum());
}
$this->Item->incrementDownloadCount($item);
unset($item);
Expand Down Expand Up @@ -192,6 +192,6 @@ public function outputCallback(&$zip, $path, $item, $bitstream, $count)
$path .= '/'.$item->getName();
}
$path .= '/'.$bitstream->getName().'.md5';
$zip->add_file($path, $bitstream->getChecksum());
$zip->addFile($path, $bitstream->getChecksum());
}
}
8 changes: 4 additions & 4 deletions modules/remoteprocessing/controllers/AdminController.php
Expand Up @@ -78,17 +78,17 @@ public function downloadAction()
$this->disableView();

ob_start();
$zip = new ZipStream('RemoteScript.zip');
$zip = new \ZipStream\ZipStream('RemoteScript.zip');
$file = BASE_PATH.'/modules/remoteprocessing/remotescript/main.py';
$zip->add_file_from_path(basename($file), $file);
$zip->addFileFromPath(basename($file), $file);
$file = BASE_PATH.'/modules/remoteprocessing/remotescript/config.cfg';
$zip->add_file_from_path(basename($file), $file);
$zip->addFileFromPath(basename($file), $file);
$dirname = BASE_PATH.'/modules/remoteprocessing/remotescript/pydas/';
$dir = opendir($dirname);

while ($file = readdir($dir)) {
if ($file != '.' && $file != '..' && !is_dir($dirname.$file)) {
$zip->add_file_from_path('pydas/'.basename($dirname.$file), $dirname.$file);
$zip->addFileFromPath('pydas/'.basename($dirname.$file), $dirname.$file);
}
}

Expand Down

0 comments on commit ed73c47

Please sign in to comment.