]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Admin.pm
index: support --max-size / publicinbox.indexMaxSize
[public-inbox.git] / lib / PublicInbox / Admin.pm
index 2d3e0281f4d71dac716b5720b255f60577075a61..62ddbe82e707e9a5ff8b1a83d999654b30790992 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2019 all contributors <meta@public-inbox.org>
+# Copyright (C) 2019-2020 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 
 # common stuff for administrative command-line tools
@@ -71,7 +71,7 @@ sub resolve_inboxes ($;$$) {
        my ($argv, $opt, $cfg) = @_;
        $opt ||= {};
 
-       $cfg //= eval { PublicInbox::Config->new };
+       $cfg //= PublicInbox::Config->new;
        if ($opt->{all}) {
                my $cfgfile = PublicInbox::Config::default_file();
                $cfg or die "--all specified, but $cfgfile not readable\n";
@@ -234,4 +234,15 @@ sub progress_prepare ($) {
        }
 }
 
+# same unit factors as git:
+sub parse_unsigned ($) {
+       my ($max_size) = @_;
+
+       $$max_size =~ /\A([0-9]+)([kmg])?\z/i or return;
+       my ($n, $unit_factor) = ($1, $2 // '');
+       my %u = ( k => 1024, m => 1024**2, g => 1024**3 );
+       $$max_size = $n * ($u{lc($unit_factor)} // 1);
+       1;
+}
+
 1;