Class PackLock


  • public class PackLock
    extends java.lang.Object
    Keeps track of a PackFile's associated .keep file.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.io.File keepFile  
    • Constructor Summary

      Constructors 
      Constructor Description
      PackLock​(java.io.File packFile, FS fs)
      Create a new lock for a pack file.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean lock​(java.lang.String msg)
      Create the pack-*.keep file, with the given message.
      void unlock()
      Remove the .keep file that holds this pack in place.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • keepFile

        private final java.io.File keepFile
    • Constructor Detail

      • PackLock

        public PackLock​(java.io.File packFile,
                        FS fs)
        Create a new lock for a pack file.
        Parameters:
        packFile - location of the pack-*.pack file.
        fs - the filesystem abstraction used by the repository.
    • Method Detail

      • lock

        public boolean lock​(java.lang.String msg)
                     throws java.io.IOException
        Create the pack-*.keep file, with the given message.
        Parameters:
        msg - message to store in the file.
        Returns:
        true if the keep file was successfully written; false otherwise.
        Throws:
        java.io.IOException - the keep file could not be written.
      • unlock

        public void unlock()
                    throws java.io.IOException
        Remove the .keep file that holds this pack in place.
        Throws:
        java.io.IOException - if deletion of .keep file failed