]> source.dussan.org Git - jgit.git/commitdiff
CachedPackUriProvider: Add size to the pack information 60/150860/3
authorIvan Frade <ifrade@google.com>
Wed, 9 Oct 2019 21:10:14 +0000 (14:10 -0700)
committerIvan Frade <ifrade@google.com>
Fri, 11 Oct 2019 21:13:17 +0000 (14:13 -0700)
The object identifying packfiles to send them via packfile-uri contains
only the uri and the hash. This is the information that goes through the
wire. It would be useful to know also the size of those packfile, for
example to track how many bytes have been offloaded to HTTP.

Add size field the CachedPackUriProvider.PackInfo object.

Change-Id: If6b921b48a4764d936141c777879b148cc80bbd3
Signed-off-by: Ivan Frade <ifrade@google.com>
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/CachedPackUriProvider.java

index 5d9f32d40b6751cabc9fe3bacb9633bda2358ff7..2f370d8c523033669ad9871aef9e83a97505adfa 100644 (file)
@@ -2077,7 +2077,7 @@ public class UploadPackTest {
                                                assertThat(protocolsSupported, hasItems("https"));
                                                if (!protocolsSupported.contains("https"))
                                                        return null;
-                                               return new PackInfo("myhash", "myuri");
+                                               return new PackInfo("myhash", "myuri", 100);
                                        }
 
                                });
index 5cbc2baeb2d02351000ca7e729f8a3ec6e4cd356..b50f7392dcb2a1e9497148f1c23ef7633384fc09 100644 (file)
@@ -76,14 +76,22 @@ public interface CachedPackUriProvider {
                private final String hash;
                private final String uri;
 
+               private final int size;
+
                /**
                 * Constructs an object containing information about a packfile.
-                * @param hash the hash of the packfile as a hexadecimal string
-                * @param uri the URI corresponding to the packfile
+                *
+                * @param hash
+                *            the hash of the packfile as a hexadecimal string
+                * @param uri
+                *            the URI corresponding to the packfile
+                * @param size
+                *            the size of the packfile in bytes
                 */
-               public PackInfo(String hash, String uri) {
+               public PackInfo(String hash, String uri, int size) {
                        this.hash = hash;
                        this.uri = uri;
+                       this.size = size;
                }
 
                /**
@@ -99,5 +107,12 @@ public interface CachedPackUriProvider {
                public String getUri() {
                        return uri;
                }
+
+               /**
+                * @return the size of the packfile in bytes (-1 if unknown)
+                */
+               public long getSize() {
+                       return size;
+               }
        }
 }