From 8d08beceb24239a17f980458f81e74d3fcdbe571 Mon Sep 17 00:00:00 2001 From: Ken Chapple Date: Tue, 22 Mar 2011 11:09:08 -0700 Subject: [PATCH] delete converted file upon rename --- controllers/C_Document.class.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/controllers/C_Document.class.php b/controllers/C_Document.class.php index 60ccaa0f9..43f1c6a2c 100644 --- a/controllers/C_Document.class.php +++ b/controllers/C_Document.class.php @@ -620,7 +620,14 @@ class C_Document extends Controller { $path = str_replace( $file_name, "", $path ); $new_url = $this->_rename_file( $path.$docname ); if ( rename( $d->get_url(), $new_url ) ) { - $d->url = $new_url; + // check the "converted" file, and delete it if it exists. It will be regenerated when report is run + $url = preg_replace("|^(.*)://|","",$d->get_url()); + $convertedFile = substr(basename($url), 0, strrpos(basename($url), '.')) . '_converted.jpg'; + $url = $GLOBALS['OE_SITE_DIR'] . '/documents/' . $patient_id . '/' . $convertedFile; + if ( file_exists( $url ) ) { + unlink( $url ); + } + $d->url = $new_url; $d->persist(); $d->populate(); $messages .= xl('Document successfully renamed.')."
"; -- 2.11.4.GIT