diff options
-rw-r--r-- | Zotlabs/Daemon/Content_importer.php | 4 | ||||
-rw-r--r-- | Zotlabs/Module/Import.php | 3 | ||||
-rw-r--r-- | Zotlabs/Module/Import_progress.php | 20 | ||||
-rw-r--r-- | view/js/mod_import_progress.js | 6 |
4 files changed, 21 insertions, 12 deletions
diff --git a/Zotlabs/Daemon/Content_importer.php b/Zotlabs/Daemon/Content_importer.php index 67f1c8e80..80c9feed1 100644 --- a/Zotlabs/Daemon/Content_importer.php +++ b/Zotlabs/Daemon/Content_importer.php @@ -47,9 +47,9 @@ class Content_importer { killme(); } - $j = json_decode($x['body'],true); + $j = json_decode($x['body'], true); - if(! is_array($j['item']) || ! count($j['item'])) { + if($j && empty($j['item'])) { PConfig::Set($channel['channel_id'], 'import', 'content_completed', 1); return; } diff --git a/Zotlabs/Module/Import.php b/Zotlabs/Module/Import.php index 5ace4e72d..7aed6469e 100644 --- a/Zotlabs/Module/Import.php +++ b/Zotlabs/Module/Import.php @@ -534,6 +534,7 @@ class Import extends Controller { if ($api_path) { $parsed = parse_url($api_path); unset($parsed['path']); + unset($parsed['query']); // store the import host so we can manually kick off item/file sync later in case anything did not work out set_pconfig($channel['channel_id'], 'import', 'host', $parsed['host']); @@ -551,7 +552,7 @@ class Import extends Controller { $until = datetime_convert(date_default_timezone_get(), date_default_timezone_get(), 'now + 1 day'); //$poll_interval = Config::Get('system', 'poll_interval', 3); - $page = 0; + $page = 0; Master::Summon(['Content_importer', sprintf('%d', $page), $since, $until, $channel['channel_address'], urlencode($hz_server)]); Master::Summon(['File_importer', sprintf('%d', $page), $channel['channel_address'], urlencode($hz_server)]); diff --git a/Zotlabs/Module/Import_progress.php b/Zotlabs/Module/Import_progress.php index d9b13e8a8..0afb6faed 100644 --- a/Zotlabs/Module/Import_progress.php +++ b/Zotlabs/Module/Import_progress.php @@ -29,14 +29,14 @@ class Import_progress extends \Zotlabs\Web\Controller { $c = PConfig::Get(local_channel(), 'import', 'content_progress'); if ($c) { - $total_cpages = floor(intval($c['items_total']) / intval($c['items_page'])); + $total_cpages = round(intval($c['items_total']) / intval($c['items_page'])); if(!$total_cpages) { - $total_cpages = 1; // because of floor + $total_cpages = 1; // because of round } $cpage = $c['last_page'] + 1; // because page count start at 0 - $cprogress = intval(floor((intval($cpage) * 100) / $total_cpages)); + $cprogress = intval(round((intval($cpage) * 100) / $total_cpages)); $ccompleted_str = t('Item sync completed!'); if(argv(1) === 'resume_itemsync' && $cprogress < 100) { @@ -50,6 +50,7 @@ class Import_progress extends \Zotlabs\Web\Controller { if ($alive) { $parsed = parse_url($alive); unset($parsed['path']); + unset($parsed['query']); $hz_server = unparse_url($parsed); $since = datetime_convert(date_default_timezone_get(), date_default_timezone_get(), '0001-01-01 00:00'); @@ -79,14 +80,14 @@ class Import_progress extends \Zotlabs\Web\Controller { $f = PConfig::Get(local_channel(), 'import', 'files_progress'); if ($f) { - $total_fpages = floor(intval($f['files_total']) / intval($f['files_page'])); + $total_fpages = round(intval($f['files_total']) / intval($f['files_page'])); if(!$total_fpages) { $total_fpages = 1; } $fpage = $f['last_page'] + 1; - $fprogress = intval(floor((intval($fpage) * 100) / $total_fpages)); + $fprogress = intval(round((intval($fpage) * 100) / $total_fpages)); $fcompleted_str = t('File sync completed!'); if(argv(1) === 'resume_filesync' && $fprogress < 100) { @@ -120,6 +121,7 @@ class Import_progress extends \Zotlabs\Web\Controller { } $fcompleted_str = t('File sync completed but no files were found!'); + } $fprogress_str = ((intval($fprogress)) ? $fprogress . '%' : $fprogress); @@ -127,13 +129,15 @@ class Import_progress extends \Zotlabs\Web\Controller { if(is_ajax()) { $ret = [ 'cprogress' => $cprogress, - 'fprogress' => $fprogress + 'ccompleted_str' => $ccompleted_str, + 'fprogress' => $fprogress, + 'fcompleted_str' => $fcompleted_str ]; json_return_and_die($ret); } - $o = replace_macros(get_markup_template("import_progress.tpl"), [ + return replace_macros(get_markup_template('import_progress.tpl'), [ '$chtitle_str' => t('Channel clone status'), '$ctitle_str' => t('Item sync status'), '$ftitle_str' => t('File sync status'), @@ -147,8 +151,6 @@ class Import_progress extends \Zotlabs\Web\Controller { '$resume_str' => t('Resume'), '$resume_helper_str' => t('Only resume if sync stalled!') ]); - - return $o; } } diff --git a/view/js/mod_import_progress.js b/view/js/mod_import_progress.js index 7aed56365..11b324862 100644 --- a/view/js/mod_import_progress.js +++ b/view/js/mod_import_progress.js @@ -30,6 +30,9 @@ $(document).ready(function() { $('#cprogress-bar').css('width', '0%'); } + $('#cprogress-completed span').html(data.ccompleted_str); + + // files if (typeof data.fprogress == 'number') { $('#fprogress-label').html(data.fprogress + '%'); @@ -50,5 +53,8 @@ $(document).ready(function() { $('#fprogress-label').html(data.fprogress); $('#fprogress-bar').css('width', '0%'); } + + $('#fprogress-completed span').html(data.fcompleted_str); + } }); |