17 include_once (
"Class.QueryDb.php");
19 define(
"VAULT_MAXENTRIESBYDIR", 1000);
20 define(
"VAULT_MAXDIRBYDIR", 100);
43 create table vaultdiskdir:specific: ( id_dir
int not null,
51 CREATE INDEX
vault_isfull:specific: on vaultdiskdir:specific: (isfull);
63 $this->specific = $def;
64 $this->dbtable = sprintf($this->dbtable_tmpl, $this->specific);
65 $this->sqlcreate = str_replace(
":specific:", $this->specific, $this->sqlcreate_tmpl);
66 $this->seq = sprintf($this->seq_tmpl, $this->specific);
83 $td = explode(
'/',
$d);
84 $dend = intval(end($td));
85 $ak = array_keys($td);
92 while (($key >= 0) && (!$good)) {
93 $prev = intval(prev($td));
103 if (!$good) $td = array_fill(0, count($td) + 1, 1);
105 return implode(
'/', $td);
110 $this->isfull = ($this->isfull ===
't');
118 $query->basic_elem->sup_where = array(
122 $query->order_by =
"id_dir";
124 $sql = sprintf(
"select * from %s where id_fs=%d and not isfull and pg_try_advisory_xact_lock(id_dir, %d) order by id_fs limit 1 for update;", pg_escape_identifier($this->dbtable) ,
$id_fs, unpack(
"i",
"VLCK") [1]);
129 $this->dirsToClose = [];
131 $needNewOneDir =
true;
132 foreach ($dirs as
$dir) {
133 $this->
Select($dir[
"id_dir"]);
135 $sql = sprintf(
"SELECT count(*) FROM vaultdiskstorage WHERE id_dir=%d", $this->id_dir);
138 $count = intval($t[0][
"count"]);
142 $needNewOneDir =
false;
146 $needNewOneDir =
false;
150 if ($needNewOneDir) {
162 foreach ($this->dirsToClose as
$dirid) {
165 $sql = sprintf(
"SELECT sum(size) FROM vaultdiskstorage WHERE id_dir=%d", $dirid);
168 $this->select($dirid);
170 $this->size = $t[0][
"sum"];
175 $this->dirsToClose = [];
183 $t =
$query->Query(0, 0,
"TABLE",
"SELECT * from vaultdiskdirstorage where id_fs=" . intval(
$id_fs) .
" order by id_dir desc limit 1");
184 $lpath = $t[0][
"l_path"];
185 $npath = $this->
nextdir($lpath);
186 $rpath = $fs[
"r_path"];
188 $absDir = sprintf(
"%s/%s", $rpath, $npath);
190 while (is_dir($absDir)) {
191 $npath = $this->
nextdir($npath);
192 $absDir = sprintf(
"%s/%s", $rpath, $npath);
197 $this->l_path = $npath;
202 $dirpath = $rpath .
"/" . $npath;
203 if (!is_dir($dirpath)) {
207 error_log(
"Vault dirs full");
208 return sprintf(_(
"cannot extend vault: %s") ,
$err);
216 if ($this->
Exists($this->l_path, $this->id_fs))
return (_(
"Directory already exists"));
217 $this->
exec_query(
"select nextval ('" . $this->seq .
"')");
219 $this->id_dir = $arr[
"nextval"];
227 $query->basic_elem->sup_where = array(
228 "l_path='" .
$path .
"'",
231 $query->Query(0, 0,
"TABLE");
238 $this->isfull =
false;
__construct($dbaccess, $id_dir= '', $def= '')
exec_query($sql, $lvl=0, $prepare=false)
Add($nopost=false, $nopre=false)
nextdir($d, $max=VAULT_MAXDIRBYDIR)
const VAULT_MAXENTRIESBYDIR
fetch_array($c, $type=PGSQL_ASSOC)
CREATE INDEX vault_isfull
modify($nopost=false, $sfields="", $nopre=false)
create sequence seq_id_vaultdiskdir
if(($docid!==0)&&(!is_numeric($docid))) $query
if($file) if($subject==""&&$file) if($subject=="") $err