19 include_once (
"Class.QueryDb.php");
21 define(
"VAULT_MAXENTRIESBYDIR", 1000);
22 define(
"VAULT_MAXDIRBYDIR", 100);
39 create table vaultdiskdir%s ( id_dir int not null,
45 create sequence seq_id_vaultdiskdir%s start 10";
50 $this->specific = $def;
51 $this->dbtable = sprintf($this->dbtable_tmpl, $this->specific);
52 $this->sqlcreate = sprintf($this->sqlcreate_tmpl, $this->specific, $this->specific);
53 $this->seq = sprintf($this->seq_tmpl, $this->specific);
65 $td = explode(
'/',
$d);
66 $dend = intval(end($td));
68 $lastkey = end(array_keys($td));
74 while (($key >= 0) && (!$good)) {
75 $prev = intval(prev($td));
85 if (!$good) $td = array_fill(0, count($td) + 1, 1);
87 return implode(
'/', $td);
94 $id_fs = $fs[
"id_fs"];
95 $query->basic_elem->sup_where = array(
103 $this->free_entries--;
106 $t =
$query->Query(0, 0,
"TABLE",
"SELECT * from vaultdiskdirstorage where id_fs=" . intval($id_fs) .
" order by id_dir desc limit 1");
107 $lpath =
$t[0][
"l_path"];
108 $npath = $this->
nextdir($lpath);
109 $rpath = $fs[
"r_path"];
112 $this->id_fs = $id_fs;
113 $this->l_path = $npath;
115 $this->free_entries--;
122 error_log(
"Vault dirs full");
123 return (_(
"no empty vault dir found") .
$err);
132 if ($this->
Exists($this->l_path, $this->id_fs))
return (_(
"Directory already exists"));
133 $res = $this->
exec_query(
"select nextval ('" . $this->seq .
"')");
135 $this->id_dir = $arr[
"nextval"];
143 $query->basic_elem->sup_where = array(
144 "l_path='" .
$path .
"'",
154 $this->free_entries+= 1;
163 $query->basic_elem->sup_where = array(
168 while (
$query->nb > 0 && (list($k, $v) = each(
$t))) $free_entries+= $v[
"free_entries"];
170 return ($free_entries);