Author: ralfbecker
New Revision: 53445
URL: http://svn.stylite.de/viewvc/egroupware?rev=53445&view=rev
Log:
shorten filenames to precision of the column (200 characters9, to not give SQL error under PostgreSQL
Modified:
branches/14.2/egroupware/api/src/Vfs/Sqlfs/StreamWrapper.php
— branches/14.2/egroupware/api/src/Vfs/Sqlfs/StreamWrapper.php (original)
+++ branches/14.2/egroupware/api/src/Vfs/Sqlfs/StreamWrapper.php Sat Aug 22 14:47:04 2015
@@ -239,7 +239,7 @@
if (self::LOG_LEVEL > 2) $query = '/* ‘.METHOD.’: ‘.LINE.’ */ '.$query;
$stmt = self::$pdo->prepare($query);
$values = array(
-
'fs_name' => self::limit_filename(Vfs::basename($path)),
'fs_dir' => $dir_stat['ino'],
// we use the mode of the dir, so files in group dirs stay accessible by all members
'fs_mode' => $dir_stat['mode'] & 0666,
@@ -661,7 +661,7 @@
’ WHERE fs_dir=:old_dir AND fs_name’.self::$case_sensitive_equal.’:old_name’);
$ok = $stmt->execute(array(
‘fs_dir’ => $to_dir_stat[‘ino’],
-
'fs_name' => self::limit_filename(Vfs::basename($path_to)),
'old_dir' => $from_dir_stat['ino'],
'old_name' => $from_stat['name'],
));
@@ -751,7 +751,7 @@
$stmt = self::$pdo->prepare(‘INSERT INTO ‘.self::TABLE.’ (fs_name,fs_dir,fs_mode,fs_uid,fs_gid,fs_size,fs_mime,fs_created,fs_modified,fs_creator’.
’) VALUES (:fs_name,:fs_dir,:fs_mode,:fs_uid,:fs_gid,:fs_size,:fs_mime,:fs_created,:fs_modified,:fs_creator)’);
if (($ok = $stmt->execute(array(
-
'fs_name' => self::limit_filename(Vfs::basename($path)),
'fs_dir' => $parent['ino'],
'fs_mode' => $parent['mode'],
'fs_uid' => $parent['uid'],
@@ -773,7 +773,7 @@
if ($stmt->execute(array(
‘fs_dir’ => $parent[‘ino’],
‘fs_active’ => self::_pdo_boolean(true),
@@ -1319,7 +1319,7 @@
unset(self::$stat_cache[Vfs::parse_url($link,PHP_URL_PATH)]);
return !!$stmt->execute(array(
-
'fs_name' => self::limit_filename(Vfs::basename($link)),
'fs_dir' => $dir_stat['ino'],
'fs_mode' => ($dir_stat['mode'] & 0666),
'fs_uid' => $dir_stat['uid'] ? $dir_stat['uid'] : Vfs::$user,
@@ -1570,6 +1570,34 @@
}
if (self::LOG_LEVEL > 1) error_log(METHOD.’(’.array2string($fs_ids).’)=’.array2string($pathes));
return is_array($fs_ids) ? $pathes : array_shift($pathes);
-
}
-
-
/**
-
- Limit filename to precision of column while keeping the extension
-
-
-
-
*/
-
static protected function limit_filename($name)
-
{
-
static $fs_name_precision = null;
-
if (!isset($fs_name_precision))
-
{
-
$fs_name_precision = $GLOBALS['egw']->db->get_column_attribute('fs_name', self::TABLE, 'phpgwapi', 'precision');
-
}
-
if (mb_strlen($name) > $fs_name_precision)
-
{
-
$parts = explode('.', $name);
-
if ($parts > 1 && mb_strlen($extension = '.'.array_pop($parts)) <= $fs_name_precision)
-
{
-
$name = mb_substr(implode('.', $parts), 0, $fs_name_precision-mb_strlen($extension)).$extension;
-
}
-
else
-
{
-
$name = mb_substr(implode('.', $parts), 0, $fs_name_precision);
-
}
-
}
-
return $name;
}
/**
eGroupWare-cvs mailing list
eGroupWare-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/egroupware-cvs