about summary refs log tree commit homepage
path: root/lib/PublicInbox/Git.pm
diff options
context:
space:
mode:
authorEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-02-17 10:19:47 +0000
committerEric Wong (Contractor, The Linux Foundation) <e@80x24.org>2018-02-19 20:10:41 +0000
commitff25a60b1b85c92a7e76a735a2c79c0205233a27 (patch)
treefda9bf18b9772637baaadbfbe094169cbf5800a7 /lib/PublicInbox/Git.pm
parent5a6bdba5bf610145f26243e73cd349658d2e2db9 (diff)
downloadpublic-inbox-ff25a60b1b85c92a7e76a735a2c79c0205233a27.tar.gz
Wrap the old Import package to enable creating new repos based
on size thresholds.  This is better than relying on time-based
rotation as LKML traffic seems to be increasing.
Diffstat (limited to 'lib/PublicInbox/Git.pm')
-rw-r--r--lib/PublicInbox/Git.pm12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm
index ea2b814e..6437643d 100644
--- a/lib/PublicInbox/Git.pm
+++ b/lib/PublicInbox/Git.pm
@@ -139,6 +139,18 @@ sub cleanup {
         _destroy($self, qw(in_c out_c pid_c));
 }
 
+# assuming a well-maintained repo, this should be a somewhat
+# accurate estimation of its size
+# TODO: show this in the WWW UI as a hint to potential cloners
+sub packed_bytes {
+        my ($self) = @_;
+        my $n = 0;
+        foreach my $p (glob("$self->{git_dir}/objects/pack/*.pack")) {
+                $n += -s $p;
+        }
+        $n
+}
+
 sub DESTROY { cleanup(@_) }
 
 1;