You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CachedPackUriProvider.java 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * Copyright (C) 2019, Google LLC. and others
  3. *
  4. * This program and the accompanying materials are made available under the
  5. * terms of the Eclipse Distribution License v. 1.0 which is available at
  6. * https://www.eclipse.org/org/documents/edl-v10.php.
  7. *
  8. * SPDX-License-Identifier: BSD-3-Clause
  9. */
  10. package org.eclipse.jgit.internal.storage.pack;
  11. import java.io.IOException;
  12. import java.util.Collection;
  13. import org.eclipse.jgit.annotations.Nullable;
  14. /**
  15. * Provider of URIs corresponding to cached packs. For use with the
  16. * "packfile-uris" feature.
  17. * @since 5.5
  18. */
  19. public interface CachedPackUriProvider {
  20. /**
  21. * @param pack the cached pack for which to check if a corresponding URI
  22. * exists
  23. * @param protocolsSupported the protocols that the client has declared
  24. * support for; if a URI is returned, it must be of one of these
  25. * protocols
  26. * @throws IOException implementations may throw this
  27. * @return if a URI corresponds to the cached pack, an object
  28. * containing the URI and some other information; null otherwise
  29. * @since 5.5
  30. */
  31. @Nullable
  32. PackInfo getInfo(CachedPack pack, Collection<String> protocolsSupported)
  33. throws IOException;
  34. /**
  35. * Information about a packfile.
  36. * @since 5.5
  37. */
  38. public static class PackInfo {
  39. private final String hash;
  40. private final String uri;
  41. private final long size;
  42. /**
  43. * Constructs an object containing information about a packfile.
  44. *
  45. * @param hash
  46. * the hash of the packfile as a hexadecimal string
  47. * @param uri
  48. * the URI corresponding to the packfile
  49. * @param size
  50. * the size of the packfile in bytes
  51. */
  52. public PackInfo(String hash, String uri, long size) {
  53. this.hash = hash;
  54. this.uri = uri;
  55. this.size = size;
  56. }
  57. /**
  58. * @return the hash of the packfile as a hexadecimal string
  59. */
  60. public String getHash() {
  61. return hash;
  62. }
  63. /**
  64. * @return the URI corresponding to the packfile
  65. */
  66. public String getUri() {
  67. return uri;
  68. }
  69. /**
  70. * @return the size of the packfile in bytes (-1 if unknown)
  71. */
  72. public long getSize() {
  73. return size;
  74. }
  75. }
  76. }