Re: [pve-devel] [PATCH zsync] fix #1907: cron entry duplicated on disable/enable

2018-09-13 Thread Wolfgang Bumiller
On Wed, Sep 12, 2018 at 02:26:57PM +0200, David wrote:
> match only the interval instead of everything in front of every "root"
> 
> Signed-off-by: David 
> ---
>  pve-zsync | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/pve-zsync b/pve-zsync
> index 10d6bac..3a137fe 100755
> --- a/pve-zsync
> +++ b/pve-zsync
> @@ -426,7 +426,7 @@ sub format_job {
>   $text = "#";
>  }
>  if ($line) {
> - $line =~ /^#*(.+) root/;
> + $line =~ /^#*(\*.+\*) root/;

While this works I think it would be better to be a bit more precise,
eg. /^#*\s*(?:\S+\s+){5}\s+root/ (match non-whitespace followed by
whitespace 5 times).

Alternatively, the initial regex could be turned to non-greedy by just
appending a '?' to the '+': /^#*(.+?) root/, that way it shouldn't match
past the first 'root'.

___
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


[pve-devel] [PATCH zsync] fix #1907: cron entry duplicated on disable/enable

2018-09-12 Thread David
match only the interval instead of everything in front of every "root"

Signed-off-by: David 
---
 pve-zsync | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pve-zsync b/pve-zsync
index 10d6bac..3a137fe 100755
--- a/pve-zsync
+++ b/pve-zsync
@@ -426,7 +426,7 @@ sub format_job {
$text = "#";
 }
 if ($line) {
-   $line =~ /^#*(.+) root/;
+   $line =~ /^#*(\*.+\*) root/;
$text .= $1;
 } else {
$text .= "*/$INTERVAL * * * *";
-- 
2.11.0


___
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel