diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2012-07-23 15:50:52 -0700 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2012-07-27 06:59:32 -0700 |
commit | 3534fa9c61e0bcc94075b99e08283bd42bbb21f0 (patch) | |
tree | a7bd06450e41b4f8de38373d785c20e2facfc25c /org.eclipse.jgit | |
parent | 778fdfaec1d1f5b16775264ebf728ee882000154 (diff) | |
download | jgit-3534fa9c61e0bcc94075b99e08283bd42bbb21f0.tar.gz jgit-3534fa9c61e0bcc94075b99e08283bd42bbb21f0.zip |
Expose some DFS APIs as public or protected
Expose class DfsReader and method DfsPackFile.hasObject() as public.
Applications may want to be able to inquire about some details of
the storage of a repository. Make this possible by exposing some
simple accessor methods.
Expose method DfsObjDatabase.clearCache() as protected, allowing
implementing subclasses to dump the cache if necessary, and force
it to reload on a future request.
Change-Id: Ic592c82d45ace9f2fa5f8d7e4bacfdce96dea969
Diffstat (limited to 'org.eclipse.jgit')
3 files changed, 22 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsObjDatabase.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsObjDatabase.java index b1290d955e..32244c1b0d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsObjDatabase.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsObjDatabase.java @@ -423,7 +423,8 @@ public abstract class DfsObjDatabase extends ObjectDatabase { return forReuse; } - void clearCache() { + /** Clears the cached list of packs, forcing them to be scanned again. */ + protected void clearCache() { packList.set(NO_PACKS); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsPackFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsPackFile.java index 419e1e8729..daad02a14b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsPackFile.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsPackFile.java @@ -272,7 +272,19 @@ public final class DfsPackFile { } } - boolean hasObject(DfsReader ctx, AnyObjectId id) throws IOException { + /** + * Check if an object is stored within this pack. + * + * @param ctx + * reader context to support reading from the backing store if + * the index is not already loaded in memory. + * @param id + * object to be located. + * @return true if the object exists in this pack; false if it does not. + * @throws IOException + * the pack index is not available, or is corrupt. + */ + public boolean hasObject(DfsReader ctx, AnyObjectId id) throws IOException { final long offset = idx(ctx).findOffset(id); return 0 < offset && !isCorrupt(offset); } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsReader.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsReader.java index 3e2a0ad5c6..6a76258ed3 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsReader.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/dfs/DfsReader.java @@ -90,7 +90,13 @@ import org.eclipse.jgit.storage.pack.PackOutputStream; import org.eclipse.jgit.storage.pack.PackWriter; import org.eclipse.jgit.util.BlockList; -final class DfsReader extends ObjectReader implements ObjectReuseAsIs { +/** + * Reader to access repository content through. + * <p> + * See the base {@link ObjectReader} documentation for details. Notably, a + * reader is not thread safe. + */ +public final class DfsReader extends ObjectReader implements ObjectReuseAsIs { /** Temporary buffer large enough for at least one raw object id. */ final byte[] tempId = new byte[OBJECT_ID_LENGTH]; |