From dc1c337910e4eb28f1d73b9e8e72c19611f9eb69 Mon Sep 17 00:00:00 2001 From: MorganDawe Date: Thu, 24 Apr 2014 13:52:54 +0000 Subject: [PATCH] Added an EntityFieldQuery back to islandora_temp_file_entry. --- includes/utilities.inc | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/includes/utilities.inc b/includes/utilities.inc index 7c0f0159..ff77bc8d 100644 --- a/includes/utilities.inc +++ b/includes/utilities.inc @@ -56,13 +56,22 @@ function islandora_convert_bytes_to_human_readable($bytes, $precision = 2) { * The file, as returned from file_save(). */ function islandora_temp_file_entry($file_uri) { - $file_name = drupal_basename($file_uri); - $file = new stdClass(); - $file->uri = $file_uri; + $query = new EntityFieldQuery(); + $result = $query + ->entityCondition('entity_type', 'file') + ->propertyCondition('uri', $file_uri) + ->execute(); + if (isset($result['file'])) { + $fid = current($result['file'])->fid; + $file = file_load($fid); + } + else { + $file = new stdClass(); + $file->uri = $file_uri; + $file->filename = drupal_basename($file_uri); + } $file->status = 0; - // Save the temp file to be cleaned up later via cron. - $return = file_save($file); - return $return; + return file_save($file); } /**