Subject: | Removing DS doesn't reduce file size by default and results in bad size in header |
Date: | Mon, 21 Oct 2013 14:45:50 -0400 |
To: | bug-RRD-Editor [...] rt.cpan.org |
From: | Benjamin Ritcey <ben+cpan [...] ritcey.com> |
I think it's an edit-in-place problem - if I call save() to a new file,
it's fine but save() without an argument produces a bad .rrd file.
This script:
--
#!/usr/bin/perl
use warnings;
use strict;
use RRD::Editor;
my $rrd_file = shift @ARGV;
my $rrd = RRD::Editor->new();
$rrd->open($rrd_file) or warn "Can't open $rrd_file: $!" and next;
my @ds_names = $rrd->DS_names();
my $last = $ds_names[-1];
$rrd->delete_DS($last);
$rrd->save() or warn "can't save file: $!";
$rrd->save('newfile.rrd') or warn "can't save new file: $!";
$rrd->open('newfile.rrd') or warn "Can't open $rrd_file: $!" and next;
$rrd->open($rrd_file) or warn "Can't open $rrd_file: $!" and next;
--
gives this result:
Show quoted text
> ls -s orig.rrd
5248 orig.rrd
Show quoted text> ./rrd_editor_header_problem orig.rrd
orig.rrd size is incorrect (is 2684584 bytes but should be 2301312 bytes)
at ./rrd_editor_header_problem line 21
Show quoted text> ls -s1 *rrd
4496 newfile.rrd
5248 orig.rrd