Merge branch 'refactoring' of git://anongit.kde.org/owncloud into refactoring
This commit is contained in:
commit
4865f423f5
|
@ -92,13 +92,14 @@ class OC_FILESTORAGE_LOCAL extends OC_FILESTORAGE{
|
||||||
}
|
}
|
||||||
public function mkdir($path){
|
public function mkdir($path){
|
||||||
if($return=mkdir($this->datadir.$path)){
|
if($return=mkdir($this->datadir.$path)){
|
||||||
$this->notifyObservers($path,OC_FILEACTION_CREATE);
|
$this->clearFolderSizeCache($path);
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
public function rmdir($path){
|
public function rmdir($path){
|
||||||
if($return=rmdir($this->datadir.$path)){
|
if($return=rmdir($this->datadir.$path)){
|
||||||
$this->notifyObservers($path,OC_FILEACTION_DELETE);
|
$this->notifyObservers($path,OC_FILEACTION_DELETE);
|
||||||
|
$this->clearFolderSizeCache($path);
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
@ -170,6 +171,7 @@ class OC_FILESTORAGE_LOCAL extends OC_FILESTORAGE{
|
||||||
public function unlink($path){
|
public function unlink($path){
|
||||||
if($return=unlink($this->datadir.$path)){
|
if($return=unlink($this->datadir.$path)){
|
||||||
$this->notifyObservers($path,OC_FILEACTION_DELETE);
|
$this->notifyObservers($path,OC_FILEACTION_DELETE);
|
||||||
|
$this->clearFolderSizeCache($path);
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
@ -189,6 +191,7 @@ class OC_FILESTORAGE_LOCAL extends OC_FILESTORAGE{
|
||||||
}
|
}
|
||||||
if($return=copy($this->datadir.$path1,$this->datadir.$path2)){
|
if($return=copy($this->datadir.$path1,$this->datadir.$path2)){
|
||||||
$this->notifyObservers($path2,OC_FILEACTION_CREATE);
|
$this->notifyObservers($path2,OC_FILEACTION_CREATE);
|
||||||
|
$this->clearFolderSizeCache($path);
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
@ -383,6 +386,7 @@ class OC_FILESTORAGE_LOCAL extends OC_FILESTORAGE{
|
||||||
if(rename($tmpFile,$this->datadir.$path)){
|
if(rename($tmpFile,$this->datadir.$path)){
|
||||||
touch($this->datadir.$path, $fileStats['mtime'], $fileStats['atime']);
|
touch($this->datadir.$path, $fileStats['mtime'], $fileStats['atime']);
|
||||||
$this->notifyObservers($path,OC_FILEACTION_CREATE);
|
$this->notifyObservers($path,OC_FILEACTION_CREATE);
|
||||||
|
$this->clearFolderSizeCache($path);
|
||||||
return true;
|
return true;
|
||||||
}else{
|
}else{
|
||||||
return false;
|
return false;
|
||||||
|
@ -394,6 +398,7 @@ class OC_FILESTORAGE_LOCAL extends OC_FILESTORAGE{
|
||||||
if(move_uploaded_file($tmpFile,$this->datadir.$path)){
|
if(move_uploaded_file($tmpFile,$this->datadir.$path)){
|
||||||
touch($this->datadir.$path, $fileStats['mtime'], $fileStats['atime']);
|
touch($this->datadir.$path, $fileStats['mtime'], $fileStats['atime']);
|
||||||
$this->notifyObservers($path,OC_FILEACTION_CREATE);
|
$this->notifyObservers($path,OC_FILEACTION_CREATE);
|
||||||
|
$this->clearFolderSizeCache($path);
|
||||||
return true;
|
return true;
|
||||||
}else{
|
}else{
|
||||||
return false;
|
return false;
|
||||||
|
@ -410,6 +415,7 @@ class OC_FILESTORAGE_LOCAL extends OC_FILESTORAGE{
|
||||||
if(is_file($dir.'/'.$item)){
|
if(is_file($dir.'/'.$item)){
|
||||||
if(unlink($dir.'/'.$item)){
|
if(unlink($dir.'/'.$item)){
|
||||||
$this->notifyObservers($dir.'/'.$item,OC_FILEACTION_DELETE);
|
$this->notifyObservers($dir.'/'.$item,OC_FILEACTION_DELETE);
|
||||||
|
$this->clearFolderSizeCache($path);
|
||||||
}
|
}
|
||||||
}elseif(is_dir($dir.'/'.$item)){
|
}elseif(is_dir($dir.'/'.$item)){
|
||||||
if (!$this->delTree($dirRelative. "/" . $item)){
|
if (!$this->delTree($dirRelative. "/" . $item)){
|
||||||
|
@ -419,6 +425,7 @@ class OC_FILESTORAGE_LOCAL extends OC_FILESTORAGE{
|
||||||
}
|
}
|
||||||
if($return=rmdir($dir)){
|
if($return=rmdir($dir)){
|
||||||
$this->notifyObservers($dir,OC_FILEACTION_DELETE);
|
$this->notifyObservers($dir,OC_FILEACTION_DELETE);
|
||||||
|
$this->clearFolderSizeCache($path);
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
@ -481,24 +488,33 @@ class OC_FILESTORAGE_LOCAL extends OC_FILESTORAGE{
|
||||||
* @return int size of folder and it's content
|
* @return int size of folder and it's content
|
||||||
*/
|
*/
|
||||||
public function calculateFolderSize($path){
|
public function calculateFolderSize($path){
|
||||||
|
if($this->is_file($path)){
|
||||||
|
$path=dirname($path);
|
||||||
|
}
|
||||||
|
$path=str_replace('//','/',$path);
|
||||||
|
if($this->is_dir($path) and substr($path,-1)!='/'){
|
||||||
|
$path.='/';
|
||||||
|
}
|
||||||
|
error_log("calc: $path");
|
||||||
$size=0;
|
$size=0;
|
||||||
if ($dh = $this->opendir($path)) {
|
if ($dh = $this->opendir($path)) {
|
||||||
while (($filename = readdir($dh)) !== false) {
|
|
||||||
if($filename!='.' and $filename!='..'){
|
|
||||||
$subFile=$path.'/'.$filename;
|
|
||||||
if($this->is_file($subFile)){
|
|
||||||
$size+=$this->filesize($subFile);
|
|
||||||
}else{
|
|
||||||
$size+=$this->calculateFolderSize($subFile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$query=OC_DB::prepare("SELECT size FROM *PREFIX*foldersize WHERE path=?");
|
$query=OC_DB::prepare("SELECT size FROM *PREFIX*foldersize WHERE path=?");
|
||||||
$hasSize=$query->execute(array($path))->fetchAll();
|
$hasSize=$query->execute(array($path))->fetchAll();
|
||||||
if(count($hasSize)>0){// yes, update it
|
if(count($hasSize)>0){// yes, update it
|
||||||
$query=OC_DB::prepare("UPDATE *PREFIX*foldersize SET size=? WHERE path=?");
|
$query=OC_DB::prepare("UPDATE *PREFIX*foldersize SET size=? WHERE path=?");
|
||||||
$result=$query->execute(array($size,$path));
|
$result=$query->execute(array($size,$path));
|
||||||
|
$size+=$hasSize[0]['size'];
|
||||||
}else{// no insert it
|
}else{// no insert it
|
||||||
|
while (($filename = readdir($dh)) !== false) {
|
||||||
|
if($filename!='.' and $filename!='..'){
|
||||||
|
$subFile=$path.'/'.$filename;
|
||||||
|
if($this->is_file($subFile)){
|
||||||
|
$size+=$this->filesize($subFile);
|
||||||
|
}else{
|
||||||
|
$size+=$this->calculateFolderSize($subFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
$query=OC_DB::prepare("INSERT INTO *PREFIX*foldersize VALUES(?,?)");
|
$query=OC_DB::prepare("INSERT INTO *PREFIX*foldersize VALUES(?,?)");
|
||||||
$result=$query->execute(array($path,$size));
|
$result=$query->execute(array($path,$size));
|
||||||
}
|
}
|
||||||
|
@ -511,13 +527,25 @@ class OC_FILESTORAGE_LOCAL extends OC_FILESTORAGE{
|
||||||
* @param string $path
|
* @param string $path
|
||||||
*/
|
*/
|
||||||
public function clearFolderSizeCache($path){
|
public function clearFolderSizeCache($path){
|
||||||
$path=dirname($path);
|
if($this->is_file($path)){
|
||||||
|
$path=dirname($path);
|
||||||
|
}
|
||||||
|
$path=str_replace('//','/',$path);
|
||||||
|
if($this->is_dir($path) and substr($path,-1)!='/'){
|
||||||
|
$path.='/';
|
||||||
|
}
|
||||||
|
error_log($path);
|
||||||
$query=OC_DB::prepare("DELETE FROM *PREFIX*foldersize WHERE path = ?");
|
$query=OC_DB::prepare("DELETE FROM *PREFIX*foldersize WHERE path = ?");
|
||||||
$result=$query->execute(array($path));
|
$result=$query->execute(array($path));
|
||||||
if($path!='/'){
|
if($path!='/' and $path!=''){
|
||||||
$parts=explode('/');
|
$parts=explode('/',$path);
|
||||||
array_pop($parts);
|
//pop empty part
|
||||||
|
$part=array_pop($parts);
|
||||||
|
if(empty($part)){
|
||||||
|
array_pop($parts);
|
||||||
|
}
|
||||||
$parent=implode('/',$parts);
|
$parent=implode('/',$parts);
|
||||||
|
$this->clearFolderSizeCache($parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ class OC_INSTALLER{
|
||||||
self::createDBUser($username,$password,$connection);
|
self::createDBUser($username,$password,$connection);
|
||||||
//use the admin login data for the new database user
|
//use the admin login data for the new database user
|
||||||
OC_CONFIG::setValue('dbuser',$username);
|
OC_CONFIG::setValue('dbuser',$username);
|
||||||
OC_CONFIG::setValue('dbpass',$password);
|
OC_CONFIG::setValue('dbpassword',$password);
|
||||||
|
|
||||||
//create the database
|
//create the database
|
||||||
self::createDatabase($dbname,$username,$connection);
|
self::createDatabase($dbname,$username,$connection);
|
||||||
|
|
|
@ -8,7 +8,14 @@ if( !OC_USER::isLoggedIn()){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$tmpl = new OC_TEMPLATE( "settings", "index", "admin" );
|
$tmpl = new OC_TEMPLATE( "settings", "index", "admin");
|
||||||
|
$used=OC_FILESYSTEM::filesize('/');
|
||||||
|
$free=disk_free_space(OC_CONFIG::getValue('datadirectory'));
|
||||||
|
$total=$free+$used;
|
||||||
|
$relative=round(($used/$total)*100);
|
||||||
|
$tmpl->assign('usage',OC_HELPER::humanFileSize($used));
|
||||||
|
$tmpl->assign('total_space',OC_HELPER::humanFileSize($total));
|
||||||
|
$tmpl->assign('usage_relative',$relative);
|
||||||
$tmpl->printPage();
|
$tmpl->printPage();
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<form id="quota">
|
<form id="quota">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Account information</legend>
|
<legend>Account information</legend>
|
||||||
<div id="quota_indicator"><div style="width:72%;"> </div></div>
|
<div id="quota_indicator"><div style="width:<?php echo $_['usage_relative'] ?>%;"> </div></div>
|
||||||
<p>You're currently using 72% (7.2GB) of your 10GB space.</p>
|
<p>You're currently using <?php echo $_['usage_relative'] ?>% (<?php echo $_['usage'] ?>) of your <?php echo $_['total_space'] ?> space.</p>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue