Browse Source

feof can only be true after a read attempt, and need to clear the stat cache.

pull/660/head
Adam Vessey 8 years ago
parent
commit
89d7c55417
  1. 4
      includes/datastream.inc

4
includes/datastream.inc

@ -459,7 +459,8 @@ function islandora_view_datastream_retrieve_file_uri(AbstractDatastream $datastr
$fp = fopen($file_uri, 'r+b'); $fp = fopen($file_uri, 'r+b');
if (flock($fp, LOCK_SH)) { if (flock($fp, LOCK_SH)) {
try { try {
if (feof($fp) && $datastream->size > 0) { fseek($fp, 0, SEEK_END);
if (ftell($fp) === 0 && $datastream->size > 0) {
// Just opened at beginning of file, if beginning == EOF, need to grab // Just opened at beginning of file, if beginning == EOF, need to grab
// it. // it.
if (!flock($fp, LOCK_EX | LOCK_NB)) { if (!flock($fp, LOCK_EX | LOCK_NB)) {
@ -482,6 +483,7 @@ function islandora_view_datastream_retrieve_file_uri(AbstractDatastream $datastr
try { try {
$datastream->getContent($file->uri); $datastream->getContent($file->uri);
clearstatcache($file->uri);
$file = file_save($file); $file = file_save($file);
if ($file->filesize != $datastream->size) { if ($file->filesize != $datastream->size) {
throw new RepositoryException(t('Size of file downloaded for chunking does not match: Got @apparent bytes when expecting @actual.', array( throw new RepositoryException(t('Size of file downloaded for chunking does not match: Got @apparent bytes when expecting @actual.', array(

Loading…
Cancel
Save