Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,16 @@ public long getPos() throws IOException {

@Override
public void sync() throws IOException {
fileStream.sync();
lock();
try {
fileStream.flush();
openNewPartIfNecessary(userDefinedMinPartSize);
Committer committer = upload.snapshotAndGetCommitter();
committer.commitAfterRecovery();
closeForCommit();
} finally {
unlock();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,16 @@ public void closeForCommitOnClosedStreamShouldFail() throws IOException {
streamUnderTest.closeForCommit().commit();
}

@Test(expected = Exception.class)
public void testSync() throws IOException {
streamUnderTest.write(bytesOf("hello"));
streamUnderTest.write(bytesOf(" world"));
streamUnderTest.sync();
assertThat(multipartUploadUnderTest, hasContent(bytesOf("hello world")));
streamUnderTest.write(randomBuffer(RefCountedBufferingFileStream.BUFFER_SIZE + 1));
assertThat(multipartUploadUnderTest, hasContent(bytesOf("hello world")));
}

// ------------------------------------------------------------------------------------------------------------
// Utils
// ------------------------------------------------------------------------------------------------------------
Expand Down