Skip to content

Commit

Permalink
Revert "set ReadContext.size to expected stream length in ReadContext…
Browse files Browse the repository at this point in the history
… passed to Storage.openInputStream(ReadContext ctx) and decrement it on read from returned InputStream"

This reverts commit d9fa23f.
  • Loading branch information
gunterze committed Oct 13, 2015
1 parent d9fa23f commit 531d254
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,6 @@ private LocationDicomInputStream openLocationInputStream(
Storage storage = getStorage(ctx, location.getStorageID());
ReadContext readContext = storage.createReadContext();
readContext.setStoragePath(location.getStoragePath());
readContext.setSize(location.getSize());
readContext.setStudyInstanceUID(studyInstanceUID);
InputStream stream = storage.openInputStream(readContext);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ public class StgCmtMDB implements MessageListener {
QLocation.location.storageID,
QLocation.location.storagePath,
QLocation.location.digest,
QLocation.location.size,
QLocation.location.status,
QInstance.instance.sopClassUID,
QInstance.instance.sopInstanceUID,
Expand Down Expand Up @@ -195,7 +194,6 @@ private boolean validateLocation(Tuple tuple, HashMap<String, Storage> storageMa
Storage storage = getStorage(storageMap, tuple.get(QLocation.location.storageID));
ReadContext readContext = storage.createReadContext();
readContext.setStoragePath(tuple.get(QLocation.location.storagePath));
readContext.setSize(tuple.get(QLocation.location.size));
readContext.setStudyInstanceUID(tuple.get(QStudy.study.studyInstanceUID));
readContext.setMessageDigest(storage.getStorageDescriptor().getMessageDigest());
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,22 +137,22 @@ public InputStream openInputStream(final ReadContext ctx) throws IOException {
public int read() throws IOException {
int read = in.read();
if (read >= 0)
ctx.incrementSize(-1);
ctx.incrementSize(1);
return read;
}

@Override
public int read(byte[] b, int off, int len) throws IOException {
int read = in.read(b, off, len);
if (read > 0)
ctx.incrementSize(-read);
ctx.incrementSize(read);
return read;
}

@Override
public long skip(long n) throws IOException {
long skip = in.skip(n);
ctx.incrementSize(-skip);
ctx.incrementSize(skip);
return skip;
}

Expand Down

0 comments on commit 531d254

Please sign in to comment.