INotify.pm: use run_command instead of open for calling diff

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2018-09-13 14:55:52 +02:00 committed by Dietmar Maurer
parent 1b505ae239
commit 69758574a1

View File

@ -19,7 +19,8 @@ use PVE::ProcFSTools;
use Clone qw(clone); use Clone qw(clone);
use Linux::Inotify2; use Linux::Inotify2;
use base 'Exporter'; use base 'Exporter';
use JSON; use JSON;
use Encode qw(encode decode);
our @EXPORT_OK = qw(read_file write_file register_file); our @EXPORT_OK = qw(read_file write_file register_file);
@ -56,13 +57,11 @@ sub ccache_compute_diff {
my $diff = ''; my $diff = '';
open (TMP, "diff -b -N -u '$filename' '$shadow'|"); my $cmd = ['/usr/bin/diff', '-b', '-N', '-u', $filename, $shadow];
PVE::Tools::run_command($cmd, noerr => 1, outfunc => sub {
while (my $line = <TMP>) { my ($line) = @_;
$diff .= $line; $diff .= decode('UTF-8', $line) . "\n";
} });
close (TMP);
$diff = undef if !$diff; $diff = undef if !$diff;