From: "Shawn O. Pearce" <spearce@spearce.org>
To: Robin Rosenberg <robin.rosenberg@dewire.com>
Cc: git@vger.kernel.org
Subject: [JGIT PATCH 07/13] Don't open a PackFile multiple times on scanForPacks
Date: Mon, 22 Dec 2008 16:27:17 -0800 [thread overview]
Message-ID: <1229992043-1053-8-git-send-email-spearce@spearce.org> (raw)
In-Reply-To: <1229992043-1053-7-git-send-email-spearce@spearce.org>
If we already have a given PackFile open in this repository then
we should reuse the existing PackFile handle.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
.../src/org/spearce/jgit/lib/PackFile.java | 5 +++++
.../src/org/spearce/jgit/lib/Repository.java | 8 +++++++-
.../src/org/spearce/jgit/lib/WindowedFile.java | 7 ++++++-
3 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/PackFile.java b/org.spearce.jgit/src/org/spearce/jgit/lib/PackFile.java
index ca5681b..fc1b6ea 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/PackFile.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/PackFile.java
@@ -94,6 +94,11 @@ final PackedObjectLoader resolveBase(final WindowCursor curs, final long ofs)
return reader(curs, ofs);
}
+ /** @return the File object which locates this pack on disk. */
+ public File getPackFile() {
+ return pack.getFile();
+ }
+
/**
* Determine if an object is contained within the pack file.
* <p>
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
index 89ad991..8f6e96e 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
@@ -825,6 +825,7 @@ synchronized (this) {
*/
public void scanForPacks() {
final ArrayList<PackFile> p = new ArrayList<PackFile>();
+ p.addAll(Arrays.asList(packs()));
for (final File d : objectsDirs())
scanForPacks(new File(d, "pack"), p);
final PackFile[] arr = new PackFile[p.size()];
@@ -843,7 +844,7 @@ public boolean accept(final File baseDir, final String n) {
}
});
if (idxList != null) {
- for (final String indexName : idxList) {
+ SCAN: for (final String indexName : idxList) {
final String n = indexName.substring(0, indexName.length() - 4);
final File idxFile = new File(packDir, n + ".idx");
final File packFile = new File(packDir, n + ".pack");
@@ -856,6 +857,11 @@ public boolean accept(final File baseDir, final String n) {
continue;
}
+ for (final PackFile p : packList) {
+ if (packFile.equals(p.getPackFile()))
+ continue SCAN;
+ }
+
try {
packList.add(new PackFile(this, idxFile, packFile));
} catch (IOException ioe) {
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/WindowedFile.java b/org.spearce.jgit/src/org/spearce/jgit/lib/WindowedFile.java
index 454f98b..f640c42 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/WindowedFile.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/WindowedFile.java
@@ -101,13 +101,18 @@ public long length() {
return length;
}
+ /** @return the absolute file object this file reads from. */
+ public File getFile() {
+ return fPath.getAbsoluteFile();
+ }
+
/**
* Get the path name of this file.
*
* @return the absolute path name of the file.
*/
public String getName() {
- return fPath.getAbsolutePath();
+ return getFile().getPath();
}
/**
--
1.6.1.rc4.301.g5497a
next prev parent reply other threads:[~2008-12-23 0:30 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-23 0:27 [JGIT PATCH 00/13] Add receive-pack server side support Shawn O. Pearce
2008-12-23 0:27 ` [JGIT PATCH 01/13] Fix invalid "double checked locking" in InflaterCache Shawn O. Pearce
2008-12-23 0:27 ` [JGIT PATCH 02/13] Cleanup stupid release of the cached Inflater in IndexPack Shawn O. Pearce
2008-12-23 0:27 ` [JGIT PATCH 03/13] Cache an Inflater inside a WindowCursor and reuse it as much as possible Shawn O. Pearce
2008-12-23 0:27 ` [JGIT PATCH 04/13] Make RefDatabase thread-safe Shawn O. Pearce
2008-12-23 0:27 ` [JGIT PATCH 05/13] Make PackFile thread-safe Shawn O. Pearce
2008-12-23 0:27 ` [JGIT PATCH 06/13] Make Repository thread-safe Shawn O. Pearce
2008-12-23 0:27 ` Shawn O. Pearce [this message]
2008-12-23 0:27 ` [JGIT PATCH 08/13] Expose RepositoryConfig.getBoolean so applications can use it Shawn O. Pearce
2008-12-23 0:27 ` [JGIT PATCH 09/13] Add AnyObjectId.copyTo(StringBuilder) Shawn O. Pearce
2008-12-23 0:27 ` [JGIT PATCH 10/13] Add compare-and-swap semantics to RefUpdate Shawn O. Pearce
2008-12-23 0:27 ` [JGIT PATCH 11/13] Allow null new ObjectId during RefUpdate.delete Shawn O. Pearce
2008-12-23 0:27 ` [JGIT PATCH 12/13] Implement the git-receive-pack process in Java Shawn O. Pearce
2008-12-23 0:27 ` [JGIT PATCH 13/13] Add basic git daemon support to publish receive-pack Shawn O. Pearce
2009-01-03 23:48 ` Robin Rosenberg
2009-01-05 2:46 ` [PATCH] Permit a wider range of repository names in jgit daemon requests Shawn O. Pearce
2009-01-05 23:07 ` Robin Rosenberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1229992043-1053-8-git-send-email-spearce@spearce.org \
--to=spearce@spearce.org \
--cc=git@vger.kernel.org \
--cc=robin.rosenberg@dewire.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).