]> git.proxmox.com Git - pve-zsync.git/commitdiff
add missing close for FH, also catch and handle exception.
authorWolfgang Link <w.link@proxmox.com>
Tue, 19 May 2015 05:02:47 +0000 (07:02 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 19 May 2015 05:32:03 +0000 (07:32 +0200)
Signed-off-by: Wolfgang Link <w.link@proxmox.com>
pve-zsync

index f2ca1c55705c4a73c1db6ea05131ce0e3e3a7ee5..47e7b590f5a63e0ea7761fb80b7b2b853fa33387 100644 (file)
--- a/pve-zsync
+++ b/pve-zsync
@@ -123,6 +123,8 @@ sub read_from_config {
 
     unlock($fh);
 
+    close($fh);
+
     my $cfg = encode_config($text);
 
     return $cfg;
@@ -365,7 +367,11 @@ sub init {
        &$add_job($vm, $name);
     }
 
-    sync($param) if !$param->{skip};
+    eval {sync($param) if !$param->{skip};};
+    if(my $err = $@) {
+       destroy($param);
+       print $err;
+    }
 }
 
 sub destroy {
@@ -440,6 +446,7 @@ sub sync {
 
        snapshot_destroy($source, $dest, $method, $source->{old_snap}) if ($source->{destroy} && $source->{old_snap});
 
+
        if ($job_status && $job_status eq "exist") {
            my $conf_name = $source->{abs_path};
            $conf_name = $source->{vmid} if $source->{vmid};
@@ -567,7 +574,7 @@ sub cron_del {
     close($fh);
     while ($text && $text =~ s/^(.*?)(\n|$)//) {
        my $line = $1.$2;
-               if ($line !~ m/.*$PROGNAME.*$source.*$name.*/){
+       if ($line !~ m/.*$PROGNAME.*$source.*$name.*/){
            $buffer .= $line;
        }
     }