diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2016-10-26 22:33:49 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2016-10-26 23:19:49 +0200 |
commit | 83555e7e303b45b9a96fbae4a7ebbff3cdb83b1c (patch) | |
tree | 23c39cf9916aeb5407a28d6b4adc5db8861d15f1 /org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal | |
parent | 0e947da72fa6b55b90922df740958b4244bb2fc3 (diff) | |
download | jgit-83555e7e303b45b9a96fbae4a7ebbff3cdb83b1c.tar.gz jgit-83555e7e303b45b9a96fbae4a7ebbff3cdb83b1c.zip |
Use AtomicObjectOutputStream in CleanFilter
Enhance and use AtomicObjectOutputStream to write temporary files in
CleanFilter.
Change-Id: I28987dad18255a9067344f94b4e836cbd183e4b1
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal')
-rw-r--r-- | org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/AtomicObjectOutputStream.java | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/AtomicObjectOutputStream.java b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/AtomicObjectOutputStream.java index 7e050b1e78..867cca5056 100644 --- a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/AtomicObjectOutputStream.java +++ b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/AtomicObjectOutputStream.java @@ -48,6 +48,7 @@ import java.nio.file.Path; import java.security.DigestOutputStream; import java.text.MessageFormat; +import org.eclipse.jgit.annotations.Nullable; import org.eclipse.jgit.internal.storage.file.LockFile; import org.eclipse.jgit.lfs.errors.CorruptLongObjectException; import org.eclipse.jgit.lfs.lib.AnyLongObjectId; @@ -83,6 +84,22 @@ public class AtomicObjectOutputStream extends OutputStream { Constants.newMessageDigest()); } + /** + * @param path + * @throws IOException + */ + public AtomicObjectOutputStream(Path path) throws IOException { + this(path, null); + } + + /** + * @return content hash of the object which was streamed through this + * stream. May return {@code null} if called before closing this stream. + */ + public @Nullable AnyLongObjectId getId() { + return id; + } + @Override public void write(int b) throws IOException { out.write(b); @@ -102,7 +119,11 @@ public class AtomicObjectOutputStream extends OutputStream { public void close() throws IOException { out.close(); if (!aborted) { - verifyHash(); + if (id != null) { + verifyHash(); + } else { + id = LongObjectId.fromRaw(out.getMessageDigest().digest()); + } locked.commit(); } } |