Remove channel cloud files from file system when

the channel is removed
This commit is contained in:
Christian Vogeley 2014-12-07 21:20:52 +01:00
parent f3789b1aeb
commit 406e97c9ad

View File

@ -207,6 +207,7 @@ function account_remove($account_id,$local = true,$unset_session=true) {
intval($account_id)
);
if ($unset_session) {
unset($_SESSION['authenticated']);
unset($_SESSION['uid']);
@ -216,6 +217,28 @@ function account_remove($account_id,$local = true,$unset_session=true) {
return $r;
}
// recursively delete a directory
function rrmdir($path)
{
if (is_dir($path) === true)
{
$files = array_diff(scandir($path), array('.', '..'));
foreach ($files as $file)
{
rrmdir(realpath($path) . '/' . $file);
}
return rmdir($path);
}
else if (is_file($path) === true)
{
return unlink($path);
}
return false;
}
function channel_remove($channel_id, $local = true, $unset_session=true) {
@ -311,6 +334,19 @@ function channel_remove($channel_id, $local = true, $unset_session=true) {
dbesc($channel['channel_hash'])
);
}
//remove from file system
$r = q("select channel_address from channel where channel_id = %d",
intval($channel_id)
);
if($r)
$channel_address = $r[0]['channel_address'] ;
if ($channel_address !== '') {
$f = 'store/' . $channel_address.'/';
logger ('delete '. $f);
if(is_dir($f))
@rrmdir($f);
}
proc_run('php','include/directory.php',$channel_id);