1

metagen.pm: fix empty gzipped content in metadata files

* fix bug with gzipped metadata
* move TODOs to TODO file
This commit is contained in:
eleksir
2019-10-20 14:11:14 +03:00
parent 236aa45b06
commit 5fe0ca517d
2 changed files with 6 additions and 8 deletions

3
TODO
View File

@@ -7,7 +7,8 @@
* paste api for some pastebins * paste api for some pastebins
* image downloader * image downloader
* repo uploader * repo uploader
* repo metadata re-generator * metagen.pm: make metadata files in atomic way
* metagen.pm: validate metadata
* simple monitoring api (common metrics: cpu, mem, swap, la, etc) * simple monitoring api (common metrics: cpu, mem, swap, la, etc)
* jabber bot: send memos to offline participants when they return * jabber bot: send memos to offline participants when they return
* announce youtube video title * announce youtube video title

View File

@@ -13,8 +13,6 @@
# repo, compressed size and uncompressed size # repo, compressed size and uncompressed size
# * MANIFEST.bz2 - list of files in each package # * MANIFEST.bz2 - list of files in each package
# TODO: make metadata in atomic way
package metagen; package metagen;
use warnings "all"; use warnings "all";
@@ -37,7 +35,6 @@ sub __pdate; # generates current date in pretty format
sub metagen($) { sub metagen($) {
my $dir = shift; my $dir = shift;
# TODO: get dir from config!
my $c = loadConf(); my $c = loadConf();
$dir = $c->{metagen}->{$dir}; $dir = $c->{metagen}->{$dir};
@@ -126,7 +123,6 @@ MD5 message digest Filename
sysopen (CS, "$dir/CHECKSUMS.md5", O_WRONLY|O_TRUNC|O_CREAT) or return ('500', 'text/plain', "Unable to open file $dir/CHECKSUMS.md5: $!\n"); sysopen (CS, "$dir/CHECKSUMS.md5", O_WRONLY|O_TRUNC|O_CREAT) or return ('500', 'text/plain', "Unable to open file $dir/CHECKSUMS.md5: $!\n");
syswrite CS, $buffer; syswrite CS, $buffer;
close CS; close CS;
$buffer = '';
my $gz = new Compress::Raw::Zlib::Deflate ( my $gz = new Compress::Raw::Zlib::Deflate (
-Level => Z_BEST_COMPRESSION, -Level => Z_BEST_COMPRESSION,
@@ -148,6 +144,7 @@ MD5 message digest Filename
} }
$gz = ''; $gz = '';
$buffer = '';
sysopen (F, "$dir/CHECKSUMS.md5.gz", O_WRONLY|O_TRUNC|O_CREAT) or return ('500', 'text/plain', "Unable to open file $dir/CHECKSUMS.md5.gz\n"); sysopen (F, "$dir/CHECKSUMS.md5.gz", O_WRONLY|O_TRUNC|O_CREAT) or return ('500', 'text/plain', "Unable to open file $dir/CHECKSUMS.md5.gz\n");
binmode F; binmode F;
syswrite F, $output; syswrite F, $output;
@@ -175,9 +172,8 @@ MD5 message digest Filename
binmode F; binmode F;
syswrite F, $buffer; syswrite F, $buffer;
close F; close F;
$buffer = '';
my $gz = new Compress::Raw::Zlib::Deflate ( $gz = new Compress::Raw::Zlib::Deflate (
-Level => Z_BEST_COMPRESSION, -Level => Z_BEST_COMPRESSION,
-CRC32 => 1, -CRC32 => 1,
-ADLER32=> 1, -ADLER32=> 1,
@@ -197,6 +193,7 @@ MD5 message digest Filename
} }
$gz = ''; $gz = '';
$buffer = '';
sysopen (F, "$dir/PACKAGES.TXT.gz", O_WRONLY|O_TRUNC|O_CREAT) or return ('500', 'text/plain', "Unable to open file $dir/PACKAGES.TXT.gz\n"); sysopen (F, "$dir/PACKAGES.TXT.gz", O_WRONLY|O_TRUNC|O_CREAT) or return ('500', 'text/plain', "Unable to open file $dir/PACKAGES.TXT.gz\n");
binmode F; binmode F;
syswrite F, $output; syswrite F, $output;