11 include_once (
"Class.QueryDb.php");
12 include_once (
"Class.DbObj.php");
13 include_once (
"VAULT/Class.VaultDiskDir.php");
30 create table vaultdiskfs%s (
37 create sequence seq_id_vaultdiskfs%s
start 10;
58 private $htaccess = <<<
EOF
67 $this->dbtable = sprintf($this->dbtable_tmpl, $this->specific);
68 $this->sqlcreate = sprintf($this->sqlcreate_tmpl, $this->specific, $this->specific);
69 $this->seq = sprintf($this->seq_tmpl, $this->specific);
76 return sprintf(_(
"%s directory not found") ,
$path);
78 if (!is_writable(
$path)) {
79 return sprintf(_(
"%s directory not writable") ,
$path);
81 if ((
$err = $this->setHtaccess(
$path)) !=
"") {
85 $this->max_size = $maxsize;
86 $this->r_path =
$path;
97 if (is_dir($this->r_path))
return true;
106 if ($this->
Exists($this->r_path))
return (_(
"File System already exists"));
107 $this->
exec_query(sprintf(
"select nextval ('%s')", pg_escape_string($this->seq)));
109 $this->id_fs = $arr[
"nextval"];
117 $query->basic_elem->sup_where = array(
118 "r_path=E'" . pg_escape_string(
$path) .
"'"
120 $query->Query(0, 0,
"TABLE");
134 $this->sd =
new VaultDiskDir($this->dbaccess,
'', $this->specific);
135 $err = $this->sd->SetFreeDir($ifs);
139 $id_dir = $this->sd->id_dir;
140 $f_path = $this->r_path .
"/" . $this->sd->l_path;
141 if (!is_dir($f_path)) {
143 return (sprintf(_(
"Failed to create directory \"%s\" in vault") , $f_path));
151 return (_(
"no empty vault file system found"));
158 return $this->sd->closeDir();
165 select vaultdiskfsstorage.*, y.size
166 from vaultdiskfsstorage, (
167 select sum(c) as size, id_fs from (
169 SELECT CASE WHEN sum(vaultdiskstorage.size) IS NULL THEN 0 ELSE sum(vaultdiskstorage.size) END AS c, vaultdiskdirstorage.id_fs
170 FROM vaultdiskstorage RIGHT JOIN vaultdiskdirstorage ON (vaultdiskdirstorage.id_fs = vaultdiskstorage.id_fs AND vaultdiskdirstorage.id_dir = vaultdiskstorage.id_dir)
171 WHERE NOT vaultdiskdirstorage.isfull
172 GROUP BY vaultdiskdirstorage.id_fs
175 (select sum(size) as c, vaultdiskdirstorage.id_fs
176 from vaultdiskdirstorage
178 group by vaultdiskdirstorage.id_fs)) as z group by id_fs) as y
179 where y.id_fs =vaultdiskfsstorage.id_fs :SQLFSNAME:
180 and vaultdiskfsstorage.max_size > (y.size + %d)
181 order by vaultdiskfsstorage.id_fs
186 $sqlName = sprintf(
"and vaultdiskfsstorage.fsname='%s'", pg_escape_string($specificFs));
191 $sql = sprintf(str_replace(
":SQLFSNAME:", $sqlName,
$sql) ,
$size);
198 return $result[
"id_fs"];
202 $sql =
"select * from vaultdiskfsstorage where id_fs not in (select id_fs from vaultdiskdirstorage ) order by id_fs;";
209 return $result[
"id_fs"];
220 select vaultdiskfsstorage.*, y.size
221 from vaultdiskfsstorage, (
222 select sum(c) as size, id_fs from (
223 (select sum(vaultdiskstorage.size) as c, vaultdiskdirstorage.id_fs
224 from vaultdiskstorage, vaultdiskdirstorage
225 where vaultdiskdirstorage.id_dir = vaultdiskstorage.id_dir and not isfull
226 group by vaultdiskdirstorage.id_fs )
228 (select sum(size) as c, vaultdiskdirstorage.id_fs
229 from vaultdiskdirstorage
231 group by vaultdiskdirstorage.id_fs)) as z group by id_fs) as y
232 where y.id_fs =vaultdiskfsstorage.id_fs
233 and vaultdiskfsstorage.id_fs = %d
244 return intval($result[
"size"]);
252 $sql =
"update vaultdiskdirstorage set size=(select sum(size) from vaultdiskstorage where id_dir=vaultdiskdirstorage.id_dir) where isfull;";
254 $sql =
"update vaultdiskdirstorage set size=0 where isfull and size is null;";
262 $query->basic_elem->sup_where = array(
263 sprintf(
"id_fs=%d",
$id_fs)
265 $t =
$query->Query(0, 0,
"TABLE");
268 if (
$sd->IsAffected()) {
269 $f_path = $t[0][
"r_path"] .
"/" .
$sd->l_path;
271 return (_(
"no vault directory found"));
274 return (_(
"no vault file system found"));
283 if ($this->IsAffected()) {
285 if (
$sd->IsAffected()) {
288 return (_(
"no vault directory found"));
291 return (_(
"no vault file system found"));
296 private function setHtaccess(
$path)
298 $htaccess = sprintf(
"%s/.htaccess",
$path);
299 if (file_exists($htaccess)) {
302 if (file_put_contents($htaccess, $this->htaccess) ===
false) {
303 return sprintf(_(
"Error writing content to '%s'.") , $htaccess);
exec_query($sql, $lvl=0, $prepare=false)
Add($nopost=false, $nopre=false)
create sequence seq_id_vaultdiskfs s start
fetch_array($c, $type=PGSQL_ASSOC)
Show($id_fs, $id_dir, &$f_path)
__construct($dbaccess, $id_fs= '')
SetFreeFs($f_size, &$id_fs, &$id_dir, &$f_path, $fsname)
createArch($maxsize, $path, $fsname="-")
DelEntry($id_fs, $id_dir, $fs)
if(($docid!==0)&&(!is_numeric($docid))) $query
if($file) if($subject==""&&$file) if($subject=="") $err
affect($array, $more=false, $reset=true)
findFreeFS($size, $specificFs="")