mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 06:30:59 +01:00
Fixed bug pointed out by lluis <lluis.faja-at-gmail.com>:
sqlfs stores files with fs_id < 100 directly under /sqlfs in the files dir. They conflict with directories created for fs_id >= 1000. --> fs_id < 100 are now in a directory /sqlfs/00 You need to run the 1.5.016 update or you will not find the content of files with fs_id < 100 anymore!
This commit is contained in:
parent
90c361b960
commit
375c328453
@ -208,7 +208,7 @@ class sqlfs_stream_wrapper implements iface_stream_wrapper
|
||||
{
|
||||
$stmt->bindParam(':'.$name,$val);
|
||||
}
|
||||
if (!$stmt->execute() || !($this->opened_fs_id = self::$pdo->lastInsertId('fs_id')))
|
||||
if (!$stmt->execute() || !($this->opened_fs_id = self::$pdo->lastInsertId('egw_sqlfs_fs_id_seq')))
|
||||
{
|
||||
$this->opened_stream = $this->opened_path = $this->opened_mode = null;
|
||||
error_log(__METHOD__."($url,$mode,$options) execute() failed: ".self::$pdo->errorInfo());
|
||||
@ -1415,8 +1415,8 @@ class sqlfs_stream_wrapper implements iface_stream_wrapper
|
||||
* Return the path of the stored content of a file if $this->operation == self::STORE2FS
|
||||
*
|
||||
* To limit the number of files stored in one directory, we create a hash from the fs_id:
|
||||
* 1 --> /1
|
||||
* 34 --> /34
|
||||
* 1 --> /00/1
|
||||
* 34 --> /00/34
|
||||
* 123 --> /01/123
|
||||
* 4567 --> /45/4567
|
||||
* 99999 --> /09/99/99999
|
||||
@ -1430,7 +1430,7 @@ class sqlfs_stream_wrapper implements iface_stream_wrapper
|
||||
{
|
||||
throw new egw_exception_wrong_parameter(__METHOD__."(id=$id) id has to be an integer!");
|
||||
}
|
||||
if (!isset($GLOBALS['egw_info']['server']['files_dir']) || $GLOBALS['egw_info']['server']['files_dir'])
|
||||
if (!isset($GLOBALS['egw_info']['server']['files_dir']))
|
||||
{
|
||||
if (is_object($GLOBALS['egw_setup']->db)) // if we run under setup, query the db for the files dir
|
||||
{
|
||||
@ -1439,16 +1439,17 @@ class sqlfs_stream_wrapper implements iface_stream_wrapper
|
||||
'config_app' => 'phpgwapi',
|
||||
),__LINE__,__FILE__)->fetchSingle();
|
||||
}
|
||||
}
|
||||
if (!$GLOBALS['egw_info']['server']['files_dir'])
|
||||
{
|
||||
throw new egw_exception_assertion_failed("\$GLOBALS['egw_info']['server']['files_dir'] not set!");
|
||||
}
|
||||
}
|
||||
$hash = array();
|
||||
for ($n = $id; $n = (int) ($n / self::HASH_MAX); )
|
||||
{
|
||||
$hash[] = sprintf('%02d',$n % self::HASH_MAX);
|
||||
}
|
||||
if (!$hash) $hash[] = '00'; // we need at least one directory, to not conflict with the dir-names
|
||||
array_unshift($hash,$id);
|
||||
|
||||
$path = '/sqlfs/'.implode('/',array_reverse($hash));
|
||||
|
@ -12,7 +12,7 @@
|
||||
/* Basic information about this app */
|
||||
$setup_info['phpgwapi']['name'] = 'phpgwapi';
|
||||
$setup_info['phpgwapi']['title'] = 'eGroupWare API';
|
||||
$setup_info['phpgwapi']['version'] = '1.5.015';
|
||||
$setup_info['phpgwapi']['version'] = '1.5.016';
|
||||
$setup_info['phpgwapi']['versions']['current_header'] = '1.29';
|
||||
$setup_info['phpgwapi']['enable'] = 3;
|
||||
$setup_info['phpgwapi']['app_order'] = 1;
|
||||
|
@ -544,3 +544,37 @@ function phpgwapi_upgrade1_5_014()
|
||||
return $GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.5.015';
|
||||
}
|
||||
|
||||
/**
|
||||
* Move files created directly in the root of sqlfs (fs_id < 100) into a /00 directory,
|
||||
* as they would conflict with dirnames in that directory.
|
||||
*
|
||||
* This update does nothing, if the files are already in the correct directory
|
||||
*/
|
||||
function phpgwapi_upgrade1_5_015()
|
||||
{
|
||||
sqlfs_stream_wrapper::_fs_path(1); // loads egw_info/server/files_dir (!)
|
||||
$sqlfs_dir = $GLOBALS['egw_info']['server']['files_dir'].'/sqlfs';
|
||||
|
||||
if (file_exists($sqlfs_dir) && ($d = opendir($sqlfs_dir)))
|
||||
{
|
||||
while(($f = readdir($d)))
|
||||
{
|
||||
if (is_file($old_name = $sqlfs_dir.'/'.$f))
|
||||
{
|
||||
if (!$zero_dir)
|
||||
{
|
||||
if ($GLOBALS['DEBUG'] && isset($_SERVER['HTTP_HOST'])) echo "<pre style='text-align: left;'>\n";
|
||||
mkdir($zero_dir = $sqlfs_dir.'/00',0777);
|
||||
echo "created dir for files with fs_id < 100: $zero_dir\n";
|
||||
}
|
||||
$new_name = $zero_dir.'/'.$f;
|
||||
if ($GLOBALS['DEBUG']) echo "moving file $old_name --> $new_name\n";
|
||||
rename($old_name,$new_name);
|
||||
}
|
||||
}
|
||||
closedir($d);
|
||||
if ($GLOBALS['DEBUG'] && isset($_SERVER['HTTP_HOST']) && $zero_dir) echo "</pre>\n";
|
||||
}
|
||||
|
||||
return $GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.5.016';
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user