AtomicObjectOutputStream getOutputStream(AnyLongObjectId id) throws IOException { Path path = getPath(id); Path parent = path.getParent(); if (parent != null) { Files.createDirectories(parent); } return new AtomicObjectOutputStream(path, id); }
/** * @param e * the exception that caused the problem */ @Override public void onError(Throwable e) { try { out.abort(); inChannel.close(); channel.close(); int status; if (e instanceof CorruptLongObjectException) { status = HttpStatus.SC_BAD_REQUEST; LOG.log(Level.WARNING, e.getMessage(), e); } else { status = HttpStatus.SC_INTERNAL_SERVER_ERROR; LOG.log(Level.SEVERE, e.getMessage(), e); } FileLfsServlet.sendError(response, status, e.getMessage()); } catch (IOException ex) { LOG.log(Level.SEVERE, ex.getMessage(), ex); } } }
@Override public void close() throws IOException { out.close(); if (!aborted) { verifyHash(); locked.commit(); } }
private void verifyHash() { AnyLongObjectId contentHash = LongObjectId .fromRaw(out.getMessageDigest().digest()); if (!contentHash.equals(id)) { abort(); throw new CorruptLongObjectException(id, contentHash, MessageFormat.format(LfsServerText.get().corruptLongObject, contentHash, id)); } }