Plugin Directory

Changeset 2639590


Ignore:
Timestamp:
12/05/2021 03:46:27 AM (4 years ago)
Author:
wkhayrattee
Message:

feat: two changes as below:

FIX: the process was blocking with wait(), let us try to make it async as getting real-time output and being async is a challenge

Enhancement: display all lines in the log henceforth so that user can see what is happening from start to end

Location:
b2-sync/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • b2-sync/trunk/README.md

    r2639404 r2639590  
    44**Requires at least:** 4.7 
    55**Tested up to:** 5.8.2 
    6 **Stable tag:** 1.1.0 
     6**Stable tag:** 1.2.0 
    77**Requires PHP:** 7.2 
    88**License:** GPLv2 or later 
    9 **License URI:** https://www.gnu.org/licenses/gpl-2.0.html
     9**License URI:** https://www.gnu.org/licenses/gpl-2.0.html 
    1010
    1111![b2-sync banner](https://ik.imagekit.io/wkhayrattee/b2sync/banner-1544x500_Hd3BLN-Sz8.png?updatedAt=1638126306180)
     
    6262## Changelog ##
    6363
     64= 1.2.0 (December 5, 2021) =
     65* FIX: the process was blocking with wait(), let us try to make it async as getting real-time output and being async is a challenge
     66* Enhancement: display all lines in the log henceforth so that user can see what is happening from start to end
     67
    6468= 1.1.0 (December 4, 2021) =
    65 
    6669* New Feature: see real-time output on the log screen
    6770* Enhancement: Allow the system to check if a sync process is already running so tha we prevent triggering any duplicate sync process
  • b2-sync/trunk/b2-sync.php

    r2639401 r2639590  
    1313 * Plugin URI: https://github.com/wkhayrattee/b2-sync
    1414 * Description: A WordPress plugin to sync assets files from wp-content/uploads onto a Backblaze B2 bucket
    15  * Version: 1.1.0
     15 * Version: 1.2.0
    1616 * Requires at least: 5.7.0
    1717 * Requires PHP: 7.2
     
    5353 */
    5454define('B2Sync_DS', DIRECTORY_SEPARATOR);
    55 define('B2Sync_VERSION', '1.1.0');
     55define('B2Sync_VERSION', '1.2.0');
    5656define('B2Sync_MINIMUM_WP_VERSION', '5.7');
    5757define('B2Sync_PLUGIN_DIR_URL', plugin_dir_url(__FILE__)); //has trailing slash at end
  • b2-sync/trunk/readme.txt

    r2639405 r2639590  
    44Requires at least: 4.7
    55Tested up to: 5.8.2
    6 Stable tag: 1.1.0
     6Stable tag: 1.2.0
    77Requires PHP: 7.2
    88License: GPLv2 or later
     
    6464== Changelog ==
    6565
     66= 1.2.0 (December 5, 2021) =
     67* FIX: the process was blocking with wait(), let us try to make it async as getting real-time output and being async is a challenge
     68* Enhancement: display all lines in the log henceforth so that user can see what is happening from start to end
     69
    6670= 1.1.0 (December 4, 2021) =
    6771* New Feature: see real-time output on the log screen
  • b2-sync/trunk/src/Core/AdminLogPage.php

    r2639397 r2639590  
    112112        }
    113113
    114         //We only want to display the latest 10 entries
    115         if ($max_lines < $lines) {
    116             for ($i = 0; $i < ($lines - $max_lines); ++$i) {
    117                 unset($log_data_array[$i]);
    118             }
    119         }
     114        //We only want to display the latest 100 entries
     115        //NOTE: Let's now display everything, so commenting the below
     116//        if ($max_lines < $lines) {
     117//            for ($i = 0; $i < ($lines - $max_lines); ++$i) {
     118//                unset($log_data_array[$i]);
     119//            }
     120//        }
    120121
    121122        //now fetch all lines
  • b2-sync/trunk/src/Core/SyncClass.php

    r2639397 r2639590  
    145145                $remote_path,
    146146            ]);
    147             $process->start();
     147            $process->setTimeout(3600);
     148
     149            //allow time process to start
     150            usleep(100);
     151
     152            /**
     153             * - Start process Asynchronously
     154             * - Get real-time Process Output (from rclone)
     155             */
     156            $process->start(function ($type, $buffer) {
     157                B2Sync_logthis('[rclone]: ' . $buffer);
     158            });
     159
     160            //we also need to check any timeout issues
     161            while ($process->isRunning()) {
     162                $process->checkTimeout();
     163            }
    148164
    149165            /**
    150166             * Getting real-time Process Output (from rclone)
    151167             * Waits until the given anonymous function returns true
     168             * [warning]: the below was obviously blocking
    152169             */
    153             $process->waitUntil(function ($type, $output) {
    154                 B2Sync_logthis('[rclone]: ' . $output);
    155 
    156                 return $output === 'Ready. Waiting for commands...';
    157             });
     170//            $process->waitUntil(function ($type, $output) {
     171//                B2Sync_logthis('[rclone]: ' . $output);
     172//
     173//                return $output === 'Ready. Waiting for commands...';
     174//            });
    158175
    159176            if ($process->isSuccessful()) {
  • b2-sync/trunk/src/Core/Utils.php

    r2639397 r2639590  
    111111                $error_msg = '[ERROR] the software "rclone" does not seem to be present on your server, please ask your server admin to install it before using this plugin';
    112112            } else {
    113                 B2Sync_logthis('[INFO] A Sync was triggered by action: ' . $action);
    114 
    115113                //Clear log file before starting next sync
    116114                $error_log_file = WP_CONTENT_DIR . B2Sync_DS . Enum::LOG_FILE_ERROR;
    117115                AdminLogPage::clearErrorLog($error_log_file);
    118116
     117                B2Sync_logthis('[INFO] A Sync was triggered by action: ' . $action);
     118
    119119                $sync = new SyncClass();
    120120                if ($sync->field_status == Enum::FIELD_STATUS_VALUE_OFF) {
    121121                    $error_msg = '[ERROR] Please enable the sync below in the dropdown or one of the field(s) is empty!';
     122
     123                    B2Sync_logthis('[ERROR] ' . $error_msg);
    122124                } else {
    123125                    $error_msg = '[INFO] Syncing has started, check the log on the sub-menu ' . Enum::ADMIN_LOG_MENU_TITLE . ' page';
     126
    124127                    $sync->start();
    125128                }
  • b2-sync/trunk/views/admin/page_log.twig

    r2639397 r2639590  
    55        <table class="form-table">
    66            <tr>
    7                 <td>(<u>Only the latest 100 entries will be displayed</u> - pay attention to the DATE!)</td>
     7                <td><u>Every line in the log file is being displayed</u></td>
     8            </tr>
     9            <tr>
     10                <td>The log file <strong>is cleared for every sync process</strong> that is launched so that you get fresh output each time</td>
    811            </tr>
    912            <tr>
Note: See TracChangeset for help on using the changeset viewer.