-
Notifications
You must be signed in to change notification settings - Fork 4
Dev-new-fixes-22 #108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dev-new-fixes-22 #108
Changes from 5 commits
5b6b484
3ed2832
9305d28
9be34d4
38b0b57
fb93aa2
679fe8d
5e81e92
c947dee
9f3576f
8b7581d
12a8598
1f51d38
29dfdbf
a3885b4
751077e
5420496
92236be
63ac40f
7a5b07f
04f5bfb
2a2bfd1
f72d460
71d9855
fdaf3c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,6 +8,7 @@ if ($var['shareCacheEnabled']!='yes') { | |||||||||||||||||
| } elseif ($var['shareUser']=='-') { | ||||||||||||||||||
| echo "<p class='notice'>User shares not enabled!</p>"; | ||||||||||||||||||
| } | ||||||||||||||||||
| $vars = @parse_ini_file("/var/local/emhttp/var.ini"); | ||||||||||||||||||
| $plugin = 'ca.mover.tuning'; | ||||||||||||||||||
| $config_file = '/boot/config/plugins/' . $plugin . '/' . $plugin . '.cfg'; | ||||||||||||||||||
| $config_default_file = '/usr/local/emhttp/plugins/' . $plugin . '/default.cfg'; | ||||||||||||||||||
|
|
@@ -30,6 +31,7 @@ $sizefDisabled = ($cfg['sizef'] != "yes") ? "disabled" : ""; | |||||||||||||||||
| $sizefSyncDisabled = ($cfg['sizefSync'] != "yes") ? "disabled" : ""; | ||||||||||||||||||
| $sparsnessfDisabled = ($cfg['sparsnessf'] != "yes") ? "disabled" : ""; | ||||||||||||||||||
| $version = ($cfg['version']); | ||||||||||||||||||
| $moverRunning = file_exists('/var/run/mover.pid'); | ||||||||||||||||||
|
|
||||||||||||||||||
| ?> | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
@@ -49,15 +51,20 @@ $.fn.toggleAttr = function(attr) { | |||||||||||||||||
|
|
||||||||||||||||||
| function updateCron() { | ||||||||||||||||||
| var cron = $("#cronSchedule").val(); | ||||||||||||||||||
| var tune_cron = $("#tune_cronSchedule").val(); | ||||||||||||||||||
| var cronEnabled = $("#forceCron").val(); | ||||||||||||||||||
| var ismoverDisabled = $("#moverDisabled").val(); | ||||||||||||||||||
| $.post("/plugins/ca.mover.tuning/updateCron.php",{cronEnabled:cronEnabled,cron:cron,ismoverDisabled:ismoverDisabled}); | ||||||||||||||||||
| $.post("/plugins/ca.mover.tuning/updateCron.php",{cronEnabled:cronEnabled,cron:cron,tune_cron:tune_cron,ismoverDisabled:ismoverDisabled}); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| function moveNow() { | ||||||||||||||||||
| $.post("/plugins/ca.mover.tuning/mover.php crond start"); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| function startTuneMover() { | ||||||||||||||||||
| $.post("/plugins/ca.mover.tuning/mover.php", { cmdStartTuneMover: 1 }); | ||||||||||||||||||
| } | ||||||||||||||||||
|
Comment on lines
+65
to
+67
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The Consider using a callback or promise to reload after the POST completes: function startTuneMover() {
-$.post("/plugins/ca.mover.tuning/mover.php", { cmdStartTuneMover: 1 });
+$.post("/plugins/ca.mover.tuning/mover.php", { cmdStartTuneMover: 1 }, function() {
+ location.reload();
+});
}Then update line 787: -<input type="button" name="StartTuneMover" value="_(Move now)_" onclick="startTuneMover(); location.reload()" ...>
+<input type="button" name="StartTuneMover" value="_(Move now)_" onclick="startTuneMover()" ...>📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
|
|
||||||||||||||||||
| function resetDefaults() { | ||||||||||||||||||
| $.post("/plugins/ca.mover.tuning/reset.php"); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
@@ -147,6 +154,16 @@ _(Disable Mover running on a schedule)_: | |||||||||||||||||
| :end | ||||||||||||||||||
|
|
||||||||||||||||||
| <div markdown="1" id="moverTuningSettings"> | ||||||||||||||||||
| <?php if (version_compare($vars['version'], '7.2.1', '>=')): ?> | ||||||||||||||||||
| _(Mover Tuning schedule)_: | ||||||||||||||||||
| : <input type='text' id='tune_cronSchedule' name='moverTuneCron' size='1' class='tune_mycron' placeholder='0 */4 * * *' value='<?=htmlspecialchars($cfg['moverTuneCron'])?>'> | ||||||||||||||||||
|
|
||||||||||||||||||
| <blockquote class="inline_help"> | ||||||||||||||||||
| <p>Runs the <strong><code>age_mover</code></strong> schedule from the Mover Tuning plugin using your custom cron entry (includes all plugin filters).</p> | ||||||||||||||||||
| <p> Cron Schedule entry example <strong>0 */4 * * *</strong>. To run at <em>every</em><strong> 4 hours</strong>. <a href="https://crontab.guru/" target="_blank" rel="noopener noreferrer"><i class="fa fa-clock-o"></i> What Is Cron</a></p> | ||||||||||||||||||
| </blockquote> | ||||||||||||||||||
| <?php endif; ?> | ||||||||||||||||||
|
|
||||||||||||||||||
| _(Test Mode (dry run))_: | ||||||||||||||||||
| : <select name='testmode' size='1' id='testmode' onchange="toggleTestModeWarning(this.value)"> | ||||||||||||||||||
| <?=mk_option($cfg['testmode'],"no",_('No'))?> | ||||||||||||||||||
|
|
@@ -704,6 +721,10 @@ _(Resynchronize all Primary files to Secondary)_: | |||||||||||||||||
| <input type="submit" name="#apply" value="_(Apply)_" id='Apply'> | ||||||||||||||||||
| <input type="button" id="DONE" value="_(Done)_" onclick="done()"> | ||||||||||||||||||
| <input type="button" id="Defaults" value="_(Defaults)_" onclick="resetDefaults(); location.reload()"> | ||||||||||||||||||
| <?if ($showMoverButton):?> | ||||||||||||||||||
| <input type="button" name="StartTuneMover" value="_(Move now)_" onclick="startTuneMover(); location.reload()" title="Run Mover Tuning ..."<?if ($moverRunning):?> disabled<?endif;?>> | ||||||||||||||||||
| <?if ($moverRunning):?><span>_(Mover is running)_</span><?endif;?> | ||||||||||||||||||
| <?endif;?> | ||||||||||||||||||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
| </span> | ||||||||||||||||||
|
|
||||||||||||||||||
| </form> | ||||||||||||||||||
|
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,4 +48,5 @@ sparsnessv="1" | |
| filetypesv="" | ||
| omoverthresh="" | ||
| cron="" | ||
| moverTuneCron="" | ||
| forceParity="no" | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,4 +1,9 @@ | ||||||||||||||||||||||||||||||||||
| #!/usr/bin/php | ||||||||||||||||||||||||||||||||||
| <?PHP | ||||||||||||||||||||||||||||||||||
| exec("/usr/local/sbin/mover.old start >> /var/log/syslog &", $output, $retval); | ||||||||||||||||||||||||||||||||||
| $vars = @parse_ini_file("/var/local/emhttp/var.ini"); | ||||||||||||||||||||||||||||||||||
|
Check warning on line 3 in source/ca.mover.tuning/usr/local/emhttp/plugins/ca.mover.tuning/moveNow.php
|
||||||||||||||||||||||||||||||||||
| if (version_compare($vars['version'], '7.2.1', '<')) { | ||||||||||||||||||||||||||||||||||
|
Check warning on line 4 in source/ca.mover.tuning/usr/local/emhttp/plugins/ca.mover.tuning/moveNow.php
|
||||||||||||||||||||||||||||||||||
| exec("/usr/local/sbin/mover.old start >> /var/log/syslog &", $output, $retval); | ||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||
| exec("/usr/local/sbin/mover start >> /var/log/syslog &", $output, $retval); | ||||||||||||||||||||||||||||||||||
|
Check failure on line 7 in source/ca.mover.tuning/usr/local/emhttp/plugins/ca.mover.tuning/moveNow.php
|
||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+3
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add null check for parse_ini_file failure. If $vars = @parse_ini_file("/var/local/emhttp/var.ini");
+if (!$vars || !isset($vars['version'])) {
+ exec("/usr/local/sbin/mover.old start >> /var/log/syslog &", $output, $retval);
+ exit;
+}
if (version_compare($vars['version'], '7.2.1', '<')) {
exec("/usr/local/sbin/mover.old start >> /var/log/syslog &", $output, $retval);
} else {
exec("/usr/local/sbin/mover start >> /var/log/syslog &", $output, $retval);
}📝 Committable suggestion
Suggested change
🧰 Tools🪛 GitHub Check: Codacy Static Code Analysis[warning] 3-3: source/ca.mover.tuning/usr/local/emhttp/plugins/ca.mover.tuning/moveNow.php#L3 [warning] 4-4: source/ca.mover.tuning/usr/local/emhttp/plugins/ca.mover.tuning/moveNow.php#L4 [failure] 7-7: source/ca.mover.tuning/usr/local/emhttp/plugins/ca.mover.tuning/moveNow.php#L7 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||
| ?> | ||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,6 +56,13 @@ | |
| logger("Option 1 set to 'start' due to version < 7.0.0\n"); | ||
| } | ||
| } | ||
| // For Unraid v7.2.1+, use $_POST for pressed move now button in plugin page | ||
| else if (version_compare($vars['version'], '7.2.1', '>=')) { | ||
|
Check warning on line 60 in source/ca.mover.tuning/usr/local/emhttp/plugins/ca.mover.tuning/mover.php
|
||
| if (isset($_POST['cmdStartTuneMover'])) { | ||
|
Check warning on line 61 in source/ca.mover.tuning/usr/local/emhttp/plugins/ca.mover.tuning/mover.php
|
||
| $args[0] = 'start'; | ||
| $option1 = $args[0]; | ||
| } | ||
| } | ||
|
||
|
|
||
| // Combine all arguments into a single string with spaces | ||
| $options = implode(' ', $args); | ||
|
|
@@ -90,7 +97,11 @@ | |
| if ($cfg['movenow'] == "yes") { | ||
| $mover_str = "/usr/local/emhttp/plugins/ca.mover.tuning/age_mover"; | ||
| } else { | ||
| $mover_str = "/usr/local/sbin/mover.old"; | ||
| if (version_compare($vars['version'], '7.2.1', '<')) { | ||
| $mover_str = "/usr/local/sbin/mover.old"; | ||
| } else { | ||
| $mover_str = "/usr/local/sbin/mover"; | ||
| } | ||
| } | ||
|
|
||
| if ($options == "stop") { | ||
|
|
@@ -117,13 +128,13 @@ | |
| //Default "move now" button has been hit. | ||
| $niceLevel = $cfg['moverNice'] ?: "0"; | ||
| $ioLevel = $cfg['moverIO'] ?: "-c 2 -n 0"; | ||
| logger("ionice $ioLevel nice -n $niceLevel /usr/local/sbin/mover.old $options"); | ||
| passthru("ionice $ioLevel nice -n $niceLevel /usr/local/sbin/mover.old $options"); | ||
| logger("ionice $ioLevel nice -n $niceLevel $mover_str $options"); | ||
| passthru("ionice $ioLevel nice -n $niceLevel $mover_str $options"); | ||
|
Check failure on line 132 in source/ca.mover.tuning/usr/local/emhttp/plugins/ca.mover.tuning/mover.php
|
||
| } | ||
| } | ||
|
|
||
| if ($cron && $cfg['moverDisabled'] == 'yes') { | ||
| logger("Mover schedule disabled"); | ||
| logger("Mover Tuning schedule disabled"); | ||
| exit(); | ||
| } | ||
|
|
||
|
|
@@ -132,7 +143,7 @@ | |
| exit(); | ||
| } | ||
|
|
||
| logger("Starting Mover ..."); | ||
| logger("Starting Mover Tuning ..."); | ||
|
|
||
| startMover(); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.