Class LooseObjects

java.lang.Object
org.eclipse.jgit.internal.storage.file.LooseObjects

class LooseObjects extends Object
Traditional file system based loose objects handler.

This is the loose object representation for a Git object database, where objects are stored loose by hashing them into directories by their ObjectId.

  • Field Details

    • LOG

      private static final org.slf4j.Logger LOG
    • MAX_LOOSE_OBJECT_STALE_READ_ATTEMPTS

      private static final int MAX_LOOSE_OBJECT_STALE_READ_ATTEMPTS
      Maximum number of attempts to read a loose object for which a stale file handle exception is thrown
      See Also:
    • directory

      private final File directory
    • unpackedObjectCache

      private final UnpackedObjectCache unpackedObjectCache
  • Constructor Details

    • LooseObjects

      LooseObjects(File dir)
      Initialize a reference to an on-disk object directory.
      Parameters:
      dir - the location of the objects directory.
  • Method Details

    • getDirectory

      File getDirectory()
      Getter for the field directory.
      Returns:
      the location of the objects directory.
    • create

      void create() throws IOException
      Throws:
      IOException
    • close

      void close()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hasCached

      boolean hasCached(AnyObjectId id)
    • has

      boolean has(AnyObjectId objectId)
      Does the requested object exist as a loose object?
      Parameters:
      objectId - identity of the object to test for existence of.
      Returns:
      true if the specified object is stored as a loose object.
    • resolve

      boolean resolve(Set<ObjectId> matches, AbbreviatedObjectId id, int matchLimit)
      Find objects matching the prefix abbreviation.
      Parameters:
      matches - set to add any located ObjectIds to. This is an output parameter.
      id - prefix to search for.
      matchLimit - maximum number of results to return. At most this many ObjectIds should be added to matches before returning.
      Returns:
      true if the matches were exhausted before reaching maxLimit.
    • open

      Throws:
      IOException
    • getObjectLoader

      ObjectLoader getObjectLoader(WindowCursor curs, File path, AnyObjectId id) throws IOException
      Provides a loader for an objectId
      Parameters:
      curs - cursor on the database
      path - the path of the loose object
      id - the object id
      Returns:
      a loader for the loose file object
      Throws:
      IOException - when file does not exist or it could not be opened
    • unpackedObjectCache

      UnpackedObjectCache unpackedObjectCache()

      Getter for the field unpackedObjectCache.

      This accessor is particularly useful to allow mocking of this class for testing purposes.
      Returns:
      the cache of the objects currently unpacked.
    • getSize

      long getSize(WindowCursor curs, AnyObjectId id) throws IOException
      Throws:
      IOException
    • insert

      Throws:
      IOException
    • tryMove

      private FileObjectDatabase.InsertLooseObjectResult tryMove(File tmp, File dst, ObjectId id) throws IOException
      Throws:
      IOException
    • fileFor

      File fileFor(AnyObjectId objectId)
      Compute the location of a loose object file.
      Parameters:
      objectId - identity of the object to get the File location for.
      Returns:
      File location of the specified loose object.