From 839118eae8b559f83080d41fb625c2c790ac8111 Mon Sep 17 00:00:00 2001 From: MorganDawe Date: Mon, 7 Apr 2014 18:15:29 +0000 Subject: [PATCH] Added Utility funciton to help clean up temp files. --- includes/utilities.inc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/includes/utilities.inc b/includes/utilities.inc index e5d60b95..d8f8b32a 100644 --- a/includes/utilities.inc +++ b/includes/utilities.inc @@ -46,6 +46,28 @@ function islandora_convert_bytes_to_human_readable($bytes, $precision = 2) { } } +function islandora_temp_file_entry($file_name, $file_uri) { + // Check for this file in the file managed table. + $list = db_select('file_managed', 'c') + ->fields('c') + ->condition('uri', $file_uri, "=") + ->execute(); + $data = $list->fetchObject(); + + dsm($data, "existing: "); + + if (!$data) { + $file = new stdClass(); + $file->uri = $file_uri; + $file->filename = $file_name; + // Temporary. + $file->status = 0; + + dsm($file, "file in islandora_temp_file_entry"); + // Save the temp file to be cleaned up later via cron. + file_save($file); + } +} /** * Creates a label for control group symbols. */