mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 21:22:40 +00:00
Lasts tests for icon cache; fixes #177
This commit is contained in:
parent
1d3725341a
commit
b62c11a43e
2 changed files with 34 additions and 8 deletions
|
@ -1287,7 +1287,7 @@ class Database {
|
||||||
// first unmark any icons which are no longer orphaned; an icon is considered orphaned if it is not used or only used by feeds which are themselves orphaned
|
// first unmark any icons which are no longer orphaned; an icon is considered orphaned if it is not used or only used by feeds which are themselves orphaned
|
||||||
$this->db->query("UPDATE arsse_icons set orphaned = null where id in (select distinct icon from arsse_feeds where icon is not null and orphaned is null)");
|
$this->db->query("UPDATE arsse_icons set orphaned = null where id in (select distinct icon from arsse_feeds where icon is not null and orphaned is null)");
|
||||||
// next mark any newly orphaned icons with the current date and time
|
// next mark any newly orphaned icons with the current date and time
|
||||||
$this->db->query("UPDATE arsse_icons set orphaned = CURRENT_TIMESTAMP where id not in (select distinct icon from arsse_feeds where icon is not null and orphaned is null)");
|
$this->db->query("UPDATE arsse_icons set orphaned = CURRENT_TIMESTAMP where orphaned is null and id not in (select distinct icon from arsse_feeds where icon is not null and orphaned is null)");
|
||||||
// finally delete icons that have been orphaned longer than the feed retention period, if a a purge threshold has been specified
|
// finally delete icons that have been orphaned longer than the feed retention period, if a a purge threshold has been specified
|
||||||
$out = 0;
|
$out = 0;
|
||||||
if (Arsse::$conf->purgeFeeds) {
|
if (Arsse::$conf->purgeFeeds) {
|
||||||
|
|
|
@ -73,10 +73,9 @@ trait SeriesCleanup {
|
||||||
'orphaned' => "datetime",
|
'orphaned' => "datetime",
|
||||||
],
|
],
|
||||||
'rows' => [
|
'rows' => [
|
||||||
[1,'http://localhost:8000/Icon/PNG',null],
|
[1,'http://localhost:8000/Icon/PNG',$daybefore],
|
||||||
[2,'http://localhost:8000/Icon/GIF',null],
|
[2,'http://localhost:8000/Icon/GIF',$daybefore],
|
||||||
[3,'http://localhost:8000/Icon/SVG1',null],
|
[3,'http://localhost:8000/Icon/SVG1',null],
|
||||||
[4,'http://localhost:8000/Icon/SVG2',null],
|
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'arsse_feeds' => [
|
'arsse_feeds' => [
|
||||||
|
@ -86,12 +85,13 @@ trait SeriesCleanup {
|
||||||
'title' => "str",
|
'title' => "str",
|
||||||
'orphaned' => "datetime",
|
'orphaned' => "datetime",
|
||||||
'size' => "int",
|
'size' => "int",
|
||||||
|
'icon' => "int",
|
||||||
],
|
],
|
||||||
'rows' => [
|
'rows' => [
|
||||||
[1,"http://example.com/1","",$daybefore,2], //latest two articles should be kept
|
[1,"http://example.com/1","",$daybefore,2,null], //latest two articles should be kept
|
||||||
[2,"http://example.com/2","",$yesterday,0],
|
[2,"http://example.com/2","",$yesterday,0,2],
|
||||||
[3,"http://example.com/3","",null,0],
|
[3,"http://example.com/3","",null,0,1],
|
||||||
[4,"http://example.com/4","",$nowish,0],
|
[4,"http://example.com/4","",$nowish,0,null],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'arsse_subscriptions' => [
|
'arsse_subscriptions' => [
|
||||||
|
@ -193,6 +193,32 @@ trait SeriesCleanup {
|
||||||
$this->compareExpectations(static::$drv, $state);
|
$this->compareExpectations(static::$drv, $state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testCleanUpOrphanedIcons(): void {
|
||||||
|
Arsse::$db->iconCleanup();
|
||||||
|
$now = gmdate("Y-m-d H:i:s");
|
||||||
|
$state = $this->primeExpectations($this->data, [
|
||||||
|
'arsse_icons' => ["id","orphaned"],
|
||||||
|
]);
|
||||||
|
$state['arsse_icons']['rows'][0][1] = null;
|
||||||
|
unset($state['arsse_icons']['rows'][1]);
|
||||||
|
$state['arsse_icons']['rows'][2][1] = $now;
|
||||||
|
$this->compareExpectations(static::$drv, $state);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCleanUpOrphanedIconsWithUnlimitedRetention(): void {
|
||||||
|
Arsse::$conf->import([
|
||||||
|
'purgeFeeds' => null,
|
||||||
|
]);
|
||||||
|
Arsse::$db->iconCleanup();
|
||||||
|
$now = gmdate("Y-m-d H:i:s");
|
||||||
|
$state = $this->primeExpectations($this->data, [
|
||||||
|
'arsse_icons' => ["id","orphaned"],
|
||||||
|
]);
|
||||||
|
$state['arsse_icons']['rows'][0][1] = null;
|
||||||
|
$state['arsse_icons']['rows'][2][1] = $now;
|
||||||
|
$this->compareExpectations(static::$drv, $state);
|
||||||
|
}
|
||||||
|
|
||||||
public function testCleanUpOldArticlesWithStandardRetention(): void {
|
public function testCleanUpOldArticlesWithStandardRetention(): void {
|
||||||
Arsse::$db->articleCleanup();
|
Arsse::$db->articleCleanup();
|
||||||
$state = $this->primeExpectations($this->data, [
|
$state = $this->primeExpectations($this->data, [
|
||||||
|
|
Loading…
Reference in a new issue