Package org.eclipse.jgit.lfs.internal
Class AtomicObjectOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- org.eclipse.jgit.lfs.internal.AtomicObjectOutputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
public class AtomicObjectOutputStream extends java.io.OutputStreamOutput stream writing content to aLockFilewhich is committed on close(). The stream checks if the hash of the stream content matches the id.
-
-
Constructor Summary
Constructors Constructor Description AtomicObjectOutputStream(java.nio.file.Path path)Constructor for AtomicObjectOutputStream.AtomicObjectOutputStream(java.nio.file.Path path, AnyLongObjectId id)Constructor for AtomicObjectOutputStream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidabort()Aborts the stream.voidclose()AnyLongObjectIdgetId()Get theid.private voidverifyHash()voidwrite(byte[] b)voidwrite(byte[] b, int off, int len)voidwrite(int b)
-
-
-
Field Detail
-
locked
private LockFile locked
-
out
private java.security.DigestOutputStream out
-
aborted
private boolean aborted
-
id
private AnyLongObjectId id
-
-
Constructor Detail
-
AtomicObjectOutputStream
public AtomicObjectOutputStream(java.nio.file.Path path, AnyLongObjectId id) throws java.io.IOExceptionConstructor for AtomicObjectOutputStream.- Parameters:
path- aPathobject.id- aAnyLongObjectIdobject.- Throws:
java.io.IOException
-
AtomicObjectOutputStream
public AtomicObjectOutputStream(java.nio.file.Path path) throws java.io.IOExceptionConstructor for AtomicObjectOutputStream.- Parameters:
path- aPathobject.- Throws:
java.io.IOException
-
-
Method Detail
-
getId
@Nullable public AnyLongObjectId getId()
Get theid.- Returns:
- content hash of the object which was streamed through this
stream. May return
nullif called before closing this stream.
-
write
public void write(int b) throws java.io.IOException- Specified by:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
write
public void write(byte[] b) throws java.io.IOException- Overrides:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
write
public void write(byte[] b, int off, int len) throws java.io.IOException- Overrides:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.OutputStream- Throws:
java.io.IOException
-
verifyHash
private void verifyHash()
-
abort
public void abort()
Aborts the stream. Temporary file will be deleted
-
-