Skip to content

Commit

Permalink
Add code to VFS hashtable driver to allow stream data to be returned
Browse files Browse the repository at this point in the history
Will allow us to replace current (duplicate) code currently in IMP.
  • Loading branch information
slusarz committed Jul 25, 2014
1 parent a190a77 commit 6fb5ebe
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
29 changes: 27 additions & 2 deletions framework/HashTable/lib/Horde/HashTable/Vfs.php
Expand Up @@ -27,6 +27,13 @@ class Horde_HashTable_Vfs
/* The virtual path to use for VFS data (temporary storage). */
const VFS_PATH = '.horde/core/psession_data';

/**
* If set, return data from get() as Horde_Stream objects, not strings.
*
* @var boolean
*/
public $stream = false;

/**
*/
protected $_persistent = true;
Expand Down Expand Up @@ -89,6 +96,7 @@ protected function _exists($keys)
foreach ($keys as $key) {
$out[$key] = $this->_vfs->exists($this->_params['vfspath'], $key);
}

return $out;
}

Expand All @@ -100,10 +108,27 @@ protected function _get($keys)

foreach ($keys as $key) {
try {
$out[$key] = $this->_vfs->read($this->_params['vfspath'], $key);
if ($this->stream) {
if (method_exists($this->_vfs, 'readStream')) {
$data = new Horde_Stream_Existing(array(
'stream' => $this->_vfs->readStream($this->_params['vfspath'], $key)
));
$data->rewind();
} else {
$data = new Horde_Stream_Temp();
$data->add(
$this->_vfs->read($this->_params['vfspath'], $key),
true
);
}
} else {
$data = $this->_vfs->read($this->_params['vfspath'], $key);
}
} catch (Horde_Vfs_Exception $e) {
$out[$key] = false;
$data = false;
}

$out[$key] = $data;
}

return $out;
Expand Down
7 changes: 7 additions & 0 deletions framework/HashTable/package.xml
Expand Up @@ -94,6 +94,13 @@
<max>3.0.0alpha1</max>
<exclude>3.0.0alpha1</exclude>
</package>
<package>
<name>Horde_Stream</name>
<channel>pear.horde.org</channel>
<min>1.2.0</min>
<max>2.0.0alpha1</max>
<exclude>2.0.0alpha1</exclude>
</package>
<package>
<name>Horde_Vfs</name>
<channel>pear.horde.org</channel>
Expand Down

0 comments on commit 6fb5ebe

Please sign in to comment.