* Filemanager/PostgreSQL: shared files were not cleaned up after expiring of 100 days not accessed under PostgreSQL

This commit is contained in:
Ralf Becker 2017-01-23 15:22:03 +01:00
parent 076030a1dc
commit da58ef5769

View File

@ -488,7 +488,7 @@ class Sharing
$async = new Api\Asyncservice(); $async = new Api\Asyncservice();
if (!$async->read('egw_sharing-tmp-cleanup')) if (!$async->read('egw_sharing-tmp-cleanup'))
{ {
$async->set_timer(array('day' => 28),'egw_sharing-tmp_cleanup','egw_sharing::tmp_cleanup',null); $async->set_timer(array('day' => 28),'egw_sharing-tmp_cleanup','EGroupware\\Api\\Vfs\\Sharing::tmp_cleanup',null);
} }
} }
@ -605,11 +605,11 @@ class Sharing
); );
if (($group_concat = self::$db->group_concat('share_id'))) $cols[] = $group_concat.' AS share_id'; if (($group_concat = self::$db->group_concat('share_id'))) $cols[] = $group_concat.' AS share_id';
// remove expired tmp-files unconditionally // remove expired tmp-files unconditionally
$having = 'HAVING share_expires < '.self::$db->quote(self::$db->to_timestamp(time())).' OR '. $having = 'HAVING MAX(share_expires) < '.self::$db->quote(self::$db->to_timestamp(time())).' OR '.
// remove without expiration date, when created over 100 days ago AND // remove without expiration date, when created over 100 days ago AND
'share_expires IS NULL AND share_created < '.self::$db->quote(self::$db->to_timestamp(time()-self::TMP_KEEP)). ' AND '. 'MAX(share_expires) IS NULL AND MAX(share_created) < '.self::$db->quote(self::$db->to_timestamp(time()-self::TMP_KEEP)). ' AND '.
// (last accessed over 100 days ago OR never) // (last accessed over 100 days ago OR never)
'(share_last_accessed IS NULL OR share_last_accessed < '.self::$db->quote(self::$db->to_timestamp(time()-self::TMP_KEEP)).')'; '(MAX(share_last_accessed) IS NULL OR MAX(share_last_accessed) < '.self::$db->quote(self::$db->to_timestamp(time()-self::TMP_KEEP)).')';
foreach(self::$db->select(self::TABLE, $cols, array( foreach(self::$db->select(self::TABLE, $cols, array(
"share_path LIKE '/home/%/.tmp/%'", "share_path LIKE '/home/%/.tmp/%'",
@ -638,7 +638,7 @@ class Sharing
} }
} }
catch (\Exception $e) { catch (\Exception $e) {
unset($e); _egw_log_exception($e);
} }
Vfs::$is_root = false; Vfs::$is_root = false;
} }