switch method of keep track of last updated for

pull/2/head
Squidly271 2017-09-10 15:42:49 -04:00
parent 175c07ae49
commit cb55a0164f
6 changed files with 34 additions and 8 deletions

Binary file not shown.

View File

@ -13,6 +13,12 @@
<PLUGIN name="&name;" author="&author;" version="&version;" launch="&launch;" pluginURL="&pluginURL;">
<CHANGES>
###2017.09.09
- Fixed: Prevent possibility of duplicate app appearing in app of the day.
- Fixed: Previously, app of the day would return errors if unRaid CSS and window width support horizontal resolution greater than 5700 pixels.
- Fixed: If multiple browser tabs opened to apps tab, detect if app database is out of sync between windows and update tab accordingly.
- Changed: Allow moderation to whitelist an application without appfeed update
###2017.09.04
- Remove arbitrary limitation of 1920 pixels across for CA (introduced via 6.4-rc8q) Instead utilize whatever limits unRaid's CSS dictates

View File

@ -1014,13 +1014,13 @@ case 'get_content':
}
if (!file_exists($infoFile)) {
$updatedSyncFlag = true;
if ( $communitySettings['appFeed'] == "true" ) {
DownloadApplicationFeed();
if (!file_exists($infoFile)) {
@unlink($communityPaths['LegacyMode']);
# $communitySettings['appFeed'] = "false"; # Do Not automatically revert. Toss up a message instead
echo "<script>$('#lastUpdated').attr('data-lastUpdated','-1');</script>";
updateSyncTime(true);
echo "<center><font size='3'><strong>Download of appfeed failed.</strong></font><br><br>Community Applications <em><b>requires</b></em> your server to have internet access. The most common cause of this failure is a failure to resolve DNS addresses. You can try and reset your modem and router to fix this issue, or set static DNS addresses (Settings - Network Settings) of <b>8.8.8.8 and 8.8.4.4</b> and try again.<br><br>Alternatively, there is also a chance that the server handling the application feed is temporarily down. Switching CA to operate in <em>Legacy Mode</em> might temporarily allow you to still utilize CA.<br>";
echo caGetMode();
echo "<script>$('#updateButton').show();</script>";
@ -1048,7 +1048,7 @@ case 'get_content':
} else {
$lastUpdated['last_updated_timestamp'] = time();
writeJsonFile($communityPaths['lastUpdated-old'],$lastUpdated);
echo "<script>$('#lastUpdated').attr('data-lastUpdated','{$lastUpdated['last_updated_timestamp']}');</script>";
updateSyncTime(true);
if (is_file($communityPaths['updateErrors'])) {
echo "<table><td><td colspan='5'><br><center>The following errors occurred:<br><br>";
@ -1061,8 +1061,7 @@ case 'get_content':
}
}
getConvertedTemplates();
$lastUpdated = readJsonFile($communityPaths['lastUpdated-old']);
echo "<script>$('#lastUpdated').attr('data-lastUpdated','{$lastUpdated['last_updated_timestamp']}');</script>";
updateSyncTime($updatedSyncFlag);
$file = readJsonFile($communityPaths['community-templates-info']);
if (!is_array($file)) break;
@ -2020,8 +2019,12 @@ case 'checkStale':
echo "false";
return;
}
$lastUpdate = readJsonFile($communityPaths['lastUpdated-old']);
if ( $lastUpdate['last_updated_timestamp'] != $webTime ) {
$lastUpdate = @file_get_contents($communityPaths['lastUpdated-sync']);
if ( ! $lastUpdate ) {
echo "false";
return;
}
if ( $lastUpdate != $webTime ) {
echo "true";
} else {
echo "false";

View File

@ -636,6 +636,22 @@ function filterMatch($filter,$searchArray) {
return false;
}
###################################################################
# #
# Used to update the last time synced to keep browsers up to date #
# #
###################################################################
function updateSyncTime($updateSyncFlag) {
global $communityPaths;
$updateTime = $updateSyncFlag ? time() : @file_get_contents($communityPaths['lastUpdated-sync']);
if ( ! $updateTime ) {
$updateTime = time();
}
echo "<script>$('#lastUpdated').attr('data-lastUpdated',$updateTime);</script>";
file_put_contents($communityPaths['lastUpdated-sync'],$updateTime);
}
############################################################################
# #

View File

@ -24,6 +24,7 @@ $communityPaths['application-feed'] = "https://tools.linuxserver.io
$communityPaths['application-feed-last-updated'] = "https://tools.linuxserver.io/unraid-docker-templates.json?last_updated=1";
$communityPaths['lastUpdated'] = $communityPaths['tempFiles']."/lastUpdated.json";
$communityPaths['lastUpdated-old'] = $communityPaths['tempFiles']."/lastUpdated-old.json";
$communityPaths['lastUpdated-sync'] = $communityPaths['tempFiles']."/lastUpdated-sync";
$communityPaths['appFeedOverride'] = $communityPaths['tempFiles']."/WhatWouldChodeDo"; /* flag to override the app feed temporarily */
$communityPaths['addConverted'] = $communityPaths['tempFiles']."/TrippingTheRift"; /* flag to indicate a rescan needed since a dockerHub container was added */
$communityPaths['convertedTemplates'] = "/boot/config/plugins/".$plugin."/private/"; /* path to private repositories on flash drive */

View File

@ -391,7 +391,7 @@ class TypeConverter {
if (!isset($array[$element])) {
# $array[$element] = "";
$array[$element] = [];
$array[$element] = [];
}
if (!$node->attributes() || $format === self::XML_NONE) {