mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-20 00:55:19 +00:00
improve removed_channel final cleanup. Hubzilla issue #386
This commit is contained in:
parent
a387868540
commit
b12dc89bb1
3 changed files with 61 additions and 16 deletions
|
@ -78,7 +78,7 @@ class Cron {
|
|||
// channels and sites that quietly vanished and prevent the directory from accumulating stale
|
||||
// or dead entries.
|
||||
|
||||
$r = q("select channel_id from channel where channel_dirdate < %s - INTERVAL %s",
|
||||
$r = q("select channel_id from channel where channel_dirdate < %s - INTERVAL %s and channel_removed = 0",
|
||||
db_utcnow(),
|
||||
db_quoteinterval('30 DAY')
|
||||
);
|
||||
|
|
|
@ -21,6 +21,21 @@ class Cron_weekly {
|
|||
|
||||
mark_orphan_hubsxchans();
|
||||
|
||||
// Find channels that were removed in the last three weeks, but
|
||||
// haven't been finally cleaned up. These should be older than 10
|
||||
// days to ensure that "purgeall" messages have gone out or bounced
|
||||
// or timed out.
|
||||
|
||||
$r = q("select channel_id from channel where channel_removed = 1 and
|
||||
channel_deleted > %s - INTERVAL %s and channel_deleted < %s - INTERVAL %s",
|
||||
db_utcnow(), db_quoteinterval('21 DAY'),
|
||||
db_utcnow(), db_quoteinterval('10 DAY')
|
||||
);
|
||||
if($r) {
|
||||
foreach($r as $rv) {
|
||||
channel_remove_final($rv['channel_id']);
|
||||
}
|
||||
}
|
||||
|
||||
// get rid of really old poco records
|
||||
|
||||
|
|
|
@ -2527,19 +2527,43 @@ function channel_remove($channel_id, $local = true, $unset_session = false) {
|
|||
}
|
||||
}
|
||||
|
||||
q("DELETE FROM app WHERE app_channel = %d", intval($channel_id));
|
||||
q("DELETE FROM atoken WHERE atoken_uid = %d", intval($channel_id));
|
||||
q("DELETE FROM chatroom WHERE cr_uid = %d", intval($channel_id));
|
||||
q("DELETE FROM conv WHERE uid = %d", intval($channel_id));
|
||||
|
||||
q("DELETE FROM groups WHERE uid = %d", intval($channel_id));
|
||||
q("DELETE FROM group_member WHERE uid = %d", intval($channel_id));
|
||||
q("DELETE FROM event WHERE uid = %d", intval($channel_id));
|
||||
q("DELETE FROM item WHERE uid = %d", intval($channel_id));
|
||||
q("DELETE FROM mail WHERE channel_id = %d", intval($channel_id));
|
||||
q("DELETE FROM menu WHERE menu_channel_id = %d", intval($channel_id));
|
||||
q("DELETE FROM menu_item WHERE mitem_channel_id = %d", intval($channel_id));
|
||||
|
||||
q("DELETE FROM notify WHERE uid = %d", intval($channel_id));
|
||||
q("DELETE FROM obj WHERE obj_channel = %d", intval($channel_id));
|
||||
|
||||
|
||||
q("DELETE FROM photo WHERE uid = %d", intval($channel_id));
|
||||
q("DELETE FROM attach WHERE uid = %d", intval($channel_id));
|
||||
q("DELETE FROM profile WHERE uid = %d", intval($channel_id));
|
||||
q("DELETE FROM pconfig WHERE uid = %d", intval($channel_id));
|
||||
q("DELETE FROM src WHERE src_channel_id = %d", intval($channel_id));
|
||||
|
||||
$r = q("select resource_id FROM attach WHERE uid = %d", intval($channel_id));
|
||||
if($r) {
|
||||
foreach($r as $rv) {
|
||||
attach_delete($channel_id,$rv['resource_id']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$r = q("select id from item where uid = %d", intval($channel_id));
|
||||
if($r) {
|
||||
foreach($r as $rv) {
|
||||
drop_item($rv['id'],false);
|
||||
}
|
||||
}
|
||||
|
||||
/// @FIXME At this stage we need to remove the file resources located under /store/$nickname
|
||||
|
||||
q("delete from abook where abook_xchan = '%s' and abook_self = 1 ",
|
||||
dbesc($channel['channel_hash'])
|
||||
|
@ -2593,19 +2617,11 @@ function channel_remove($channel_id, $local = true, $unset_session = false) {
|
|||
}
|
||||
|
||||
//remove from file system
|
||||
$r = q("select channel_address from channel where channel_id = %d limit 1",
|
||||
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);
|
||||
}
|
||||
|
||||
$f = 'store/' . $channel['channel_address'];
|
||||
if(is_dir($f)) {
|
||||
@rrmdir($f);
|
||||
}
|
||||
|
||||
Zotlabs\Daemon\Master::Summon(array('Directory',$channel_id));
|
||||
|
@ -2616,6 +2632,20 @@ function channel_remove($channel_id, $local = true, $unset_session = false) {
|
|||
}
|
||||
}
|
||||
|
||||
// execute this at least a week after removing a channel
|
||||
|
||||
function channel_remove_final($channel_id) {
|
||||
|
||||
q("delete from abook where abook_channel = %d", intval($channel_id));
|
||||
q("delete from abconfig where chan = %d", intval($channel_id));
|
||||
q("delete from pconfig where uid = %d", intval($channel_id));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief This checks if a channel is allowed to publish executable code.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue