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.OutputStream
Output stream writing content to aLockFile
which 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 void
abort()
Aborts the stream.void
close()
AnyLongObjectId
getId()
Get theid
.private void
verifyHash()
void
write(byte[] b)
void
write(byte[] b, int off, int len)
void
write(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.IOException
Constructor for AtomicObjectOutputStream.- Parameters:
path
- aPath
object.id
- aAnyLongObjectId
object.- Throws:
java.io.IOException
-
AtomicObjectOutputStream
public AtomicObjectOutputStream(java.nio.file.Path path) throws java.io.IOException
Constructor for AtomicObjectOutputStream.- Parameters:
path
- aPath
object.- 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
null
if called before closing this stream.
-
write
public void write(int b) throws java.io.IOException
- Specified by:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
write
public void write(byte[] b) throws java.io.IOException
- Overrides:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
write
public void write(byte[] b, int off, int len) throws java.io.IOException
- Overrides:
write
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
verifyHash
private void verifyHash()
-
abort
public void abort()
Aborts the stream. Temporary file will be deleted
-
-