Creating an own column (fs_link) for symlinks, as fs_content is a BLOB

and therefore not aware of charsets
This commit is contained in:
Ralf Becker 2009-05-12 07:21:57 +00:00
parent 5b2da78e32
commit 6617bec9ef
4 changed files with 25 additions and 12 deletions

View File

@ -901,9 +901,8 @@ class sqlfs_stream_wrapper implements iface_stream_wrapper
return false; return false;
} }
$this->opened_dir = array(); $this->opened_dir = array();
$query = 'SELECT fs_id,fs_name,fs_mode,fs_uid,fs_gid,fs_size,fs_mime,fs_created,fs_modified'. $query = 'SELECT fs_id,fs_name,fs_mode,fs_uid,fs_gid,fs_size,fs_mime,fs_created,fs_modified,fs_link'.
",CASE fs_mime WHEN '".self::SYMLINK_MIME_TYPE."' THEN fs_content ELSE NULL END AS readlink FROM ".self::TABLE. ' FROM '.self::TABLE." WHERE fs_dir=? ORDER BY fs_mime='httpd/unix-directory' DESC, fs_name ASC";
" WHERE fs_dir=? ORDER BY fs_mime='httpd/unix-directory' DESC, fs_name ASC";
//if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query; //if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query;
if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__."($url,$options)".' */ '.$query; if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__."($url,$options)".' */ '.$query;
@ -971,9 +970,8 @@ class sqlfs_stream_wrapper implements iface_stream_wrapper
{ {
self::_pdo(); self::_pdo();
} }
$base_query = 'SELECT fs_id,fs_name,fs_mode,fs_uid,fs_gid,fs_size,fs_mime,fs_created,fs_modified'. $base_query = 'SELECT fs_id,fs_name,fs_mode,fs_uid,fs_gid,fs_size,fs_mime,fs_created,fs_modified,fs_link'.
",CASE fs_mime WHEN '".self::SYMLINK_MIME_TYPE."' THEN fs_content ELSE NULL END AS readlink FROM ".self::TABLE. ' FROM '.self::TABLE.' WHERE fs_name'.self::$case_sensitive_equal.'? AND fs_dir=';
' WHERE fs_name'.self::$case_sensitive_equal.'? AND fs_dir=';
$parts = explode('/',$path); $parts = explode('/',$path);
// if we have extendes acl access to the url, we dont need and can NOT include the sql for the readable check // if we have extendes acl access to the url, we dont need and can NOT include the sql for the readable check
@ -1153,8 +1151,8 @@ class sqlfs_stream_wrapper implements iface_stream_wrapper
if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$target','$link') returning false! (!stat('$link') || !is_writable('$dir'))"); if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$target','$link') returning false! (!stat('$link') || !is_writable('$dir'))");
return false; // $link already exists or parent dir does not return false; // $link already exists or parent dir does not
} }
$query = 'INSERT INTO '.self::TABLE.' (fs_name,fs_dir,fs_mode,fs_uid,fs_gid,fs_created,fs_modified,fs_creator,fs_mime,fs_size,fs_content'. $query = 'INSERT INTO '.self::TABLE.' (fs_name,fs_dir,fs_mode,fs_uid,fs_gid,fs_created,fs_modified,fs_creator,fs_mime,fs_size,fs_link'.
') VALUES (:fs_name,:fs_dir,:fs_mode,:fs_uid,:fs_gid,:fs_created,:fs_modified,:fs_creator,:fs_mime,:fs_size,:fs_content)'; ') VALUES (:fs_name,:fs_dir,:fs_mode,:fs_uid,:fs_gid,:fs_created,:fs_modified,:fs_creator,:fs_mime,:fs_size,:fs_link)';
if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query; if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query;
$stmt = self::$pdo->prepare($query); $stmt = self::$pdo->prepare($query);
unset(self::$stat_cache[$link]); unset(self::$stat_cache[$link]);
@ -1170,7 +1168,7 @@ class sqlfs_stream_wrapper implements iface_stream_wrapper
'fs_creator' => egw_vfs::$user, 'fs_creator' => egw_vfs::$user,
'fs_mime' => self::SYMLINK_MIME_TYPE, 'fs_mime' => self::SYMLINK_MIME_TYPE,
'fs_size' => bytes($target), 'fs_size' => bytes($target),
'fs_content' => $target, 'fs_link' => $target,
)); ));
} }
@ -1429,7 +1427,7 @@ class sqlfs_stream_wrapper implements iface_stream_wrapper
'nlink' => $info['fs_mime'] == self::DIR_MIME_TYPE ? 2 : 1, 'nlink' => $info['fs_mime'] == self::DIR_MIME_TYPE ? 2 : 1,
// eGW addition to return some extra values // eGW addition to return some extra values
'mime' => $info['fs_mime'], 'mime' => $info['fs_mime'],
'readlink' => $info['readlink'], 'readlink' => $info['fs_link'],
); );
if (self::LOG_LEVEL > 1) error_log(__METHOD__."($info[name]) = ".array2string($stat)); if (self::LOG_LEVEL > 1) error_log(__METHOD__."($info[name]) = ".array2string($stat));
return $stat; return $stat;

View File

@ -12,7 +12,7 @@
/* Basic information about this app */ /* Basic information about this app */
$setup_info['phpgwapi']['name'] = 'phpgwapi'; $setup_info['phpgwapi']['name'] = 'phpgwapi';
$setup_info['phpgwapi']['title'] = 'eGroupWare API'; $setup_info['phpgwapi']['title'] = 'eGroupWare API';
$setup_info['phpgwapi']['version'] = '1.7.001'; $setup_info['phpgwapi']['version'] = '1.7.002';
$setup_info['phpgwapi']['versions']['current_header'] = '1.29'; $setup_info['phpgwapi']['versions']['current_header'] = '1.29';
$setup_info['phpgwapi']['enable'] = 3; $setup_info['phpgwapi']['enable'] = 3;
$setup_info['phpgwapi']['app_order'] = 1; $setup_info['phpgwapi']['app_order'] = 1;
@ -75,3 +75,4 @@ $setup_info['groupdav']['author'] = $setup_info['groupdav']['maintainer'] = arra
'email' => 'RalfBecker@outdoor-training.de' 'email' => 'RalfBecker@outdoor-training.de'
); );
$setup_info['groupdav']['license'] = 'GPL'; $setup_info['groupdav']['license'] = 'GPL';

View File

@ -446,7 +446,8 @@ $phpgw_baseline = array(
'fs_creator' => array('type' => 'int','precision' => '4','nullable' => False), 'fs_creator' => array('type' => 'int','precision' => '4','nullable' => False),
'fs_modifier' => array('type' => 'int','precision' => '4'), 'fs_modifier' => array('type' => 'int','precision' => '4'),
'fs_active' => array('type' => 'bool','nullable' => False,'default' => 't'), 'fs_active' => array('type' => 'bool','nullable' => False,'default' => 't'),
'fs_content' => array('type' => 'blob') 'fs_content' => array('type' => 'blob'),
'fs_link' => array('type' => 'varchar','precision' => '255')
), ),
'pk' => array('fs_id'), 'pk' => array('fs_id'),
'fk' => array(), 'fk' => array(),

View File

@ -27,3 +27,16 @@ function phpgwapi_upgrade1_6_001()
{ {
return $GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.7.001'; return $GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.7.001';
} }
function phpgwapi_upgrade1_7_001()
{
$GLOBALS['egw_setup']->oProc->AddColumn('egw_sqlfs','fs_link',array(
'type' => 'varchar',
'precision' => '255'
));
// moving symlinks from fs_content to fs_link
$GLOBALS['egw_setup']->oProc->query("UPDATE egw_sqlfs SET fs_link=fs_content,fs_content=NULL WHERE fs_mime='application/x-symlink'",__LINE__,__FILE__);
return $GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.7.002';
}