summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties1
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java1
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryPackParser.java15
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java20
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java14
5 files changed, 51 insertions, 0 deletions
diff --git a/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties b/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties
index a5a5cf6c99..57c08f3691 100644
--- a/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties
+++ b/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties
@@ -378,6 +378,7 @@ packHasUnresolvedDeltas=pack has unresolved deltas
packingCancelledDuringObjectsWriting=Packing cancelled during objects writing
packObjectCountMismatch=Pack object count mismatch: pack {0} index {1}: {2}
packRefs=Pack refs
+packSizeNotSetYet=Pack size not yet set since it has not yet been received
packTooLargeForIndexVersion1=Pack too large for index version 1
packWriterStatistics=Total {0,number,#0} (delta {1,number,#0}), reused {2,number,#0} (delta {3,number,#0})
panicCantRenameIndexFile=Panic: index file {0} must be renamed to replace {1}; until then repository is corrupt
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
index 8ca425a15b..40e74ed892 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
@@ -440,6 +440,7 @@ public class JGitText extends TranslationBundle {
/***/ public String packingCancelledDuringObjectsWriting;
/***/ public String packObjectCountMismatch;
/***/ public String packRefs;
+ /***/ public String packSizeNotSetYet;
/***/ public String packTooLargeForIndexVersion1;
/***/ public String packWriterStatistics;
/***/ public String panicCantRenameIndexFile;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryPackParser.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryPackParser.java
index 1846c47ed2..a186b81470 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryPackParser.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryPackParser.java
@@ -169,6 +169,21 @@ public class ObjectDirectoryPackParser extends PackParser {
}
@Override
+ public long getPackSize() {
+ if (newPack == null)
+ return super.getPackSize();
+
+ File pack = newPack.getPackFile();
+ long size = pack.length();
+ String p = pack.getAbsolutePath();
+ String i = p.substring(0, p.length() - ".pack".length()) + ".idx"; //$NON-NLS-1$ //$NON-NLS-2$
+ File idx = new File(i);
+ if (idx.exists() && idx.isFile())
+ size += idx.length();
+ return size;
+ }
+
+ @Override
public PackLock parse(ProgressMonitor receiving, ProgressMonitor resolving)
throws IOException {
tmpPack = File.createTempFile("incoming_", ".pack", db.getDirectory()); //$NON-NLS-1$ //$NON-NLS-2$
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java
index 67ab9ef3a6..68b3262a0b 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java
@@ -240,6 +240,9 @@ public abstract class BaseReceivePack {
/** Total pack size limit */
private long maxPackSizeLimit = -1;
+ /** The size of the received pack, including index size */
+ private Long packSize;
+
/**
* Create a new pack receive for an open repository.
*
@@ -720,6 +723,22 @@ public abstract class BaseReceivePack {
return msgOutWrapper;
}
+ /**
+ * Get the size of the received pack file including the index size.
+ *
+ * This can only be called if the pack is already received.
+ *
+ * @return the size of the received pack including index size
+ * @throws IllegalStateException
+ * if called before the pack has been received
+ * @since 3.3
+ */
+ public long getPackSize() {
+ if (packSize != null)
+ return packSize.longValue();
+ throw new IllegalStateException(JGitText.get().packSizeNotSetYet);
+ }
+
/** @return true if any commands to be executed have been read. */
protected boolean hasCommands() {
return !commands.isEmpty();
@@ -968,6 +987,7 @@ public abstract class BaseReceivePack {
parser.setLockMessage(lockMsg);
parser.setMaxObjectSizeLimit(maxObjectSizeLimit);
packLock = parser.parse(receiving, resolving);
+ packSize = Long.valueOf(parser.getPackSize());
ins.flush();
} finally {
ins.release();
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java
index e16cce0e3d..93522c1e92 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java
@@ -419,6 +419,20 @@ public abstract class PackParser {
}
/**
+ * Get the size of the parsed pack.
+ *
+ * This will also include the pack index size if an index was created. This
+ * method should only be called after pack parsing is finished.
+ *
+ * @return the pack size (including the index size) or -1 if the size cannot
+ * be determined
+ * @since 3.3
+ */
+ public long getPackSize() {
+ return -1;
+ }
+
+ /**
* Parse the pack stream.
*
* @param progress