From 519e2cced598b29070a1a3dc7f22065b2c8be999 Mon Sep 17 00:00:00 2001 From: Karl Cordes Date: Mon, 26 Sep 2011 17:41:17 +1000 Subject: [PATCH] Vault fixes. Added vault.locking --- vendors/shells/vault.php | 22 ++++++++++++++++++---- views/elements/email/html/email_pdf.ctp | 2 +- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/vendors/shells/vault.php b/vendors/shells/vault.php index 7e75537e..2213f9c3 100755 --- a/vendors/shells/vault.php +++ b/vendors/shells/vault.php @@ -25,22 +25,32 @@ class VaultShell extends Shell { $testing = 0; //Whether to actually move the emails. 1=test, 0=production + + if($testing == 1) { $ripmime_path = '/opt/local/bin/ripmime'; $email_dir = '/Users/karlcordes/Sites/quotenik/app/emails'; $vault_dir = '/Users/karlcordes/Sites/quotenik/app/vaultmsgs'; $processed_dir = '/Users/karlcordes/Sites/quotenik/app/processed_vaultmsgs'; - + $lockfile = '/Users/karlcordes/Sites/quotenik/app/vault.lock'; } else { $ripmime_path = '/usr/local/bin/ripmime'; $email_dir = '/var/www/cakephp/app/emails'; $vault_dir = '/var/www/cakephp/app/vaultmsgs'; $processed_dir = '/var/www/cakephp/app/processed_vaultmsgs'; + $lockfile = '/var/www/cakephp/app/vault.lock'; } - - - + + if(file_exists($lockfile)) { + die("Error: Another process is currently running. Terminating this one"); + } + else { + if(!touch($lockfile)) { + die("FATAL ERROR: Unable to create vault.lock"); + } + } + /* Find the strings we want to look for in the subjects. Build arrays * using the string as the keys, IDs as the value @@ -376,6 +386,10 @@ class VaultShell extends Shell { } + if(!unlink($lockfile)) { + die("FATAL ERROR: Unable to remove vault.lock. No further Vault instances can run!"); + } + } diff --git a/views/elements/email/html/email_pdf.ctp b/views/elements/email/html/email_pdf.ctp index 667c901a..6d85e2ed 100755 --- a/views/elements/email/html/email_pdf.ctp +++ b/views/elements/email/html/email_pdf.ctp @@ -3,7 +3,7 @@ Dear ,

Please see the attached PDF of your .
If you have any enquiries, please contact link($enquiry['User']['first_name'].' '.$enquiry['User']['last_name'], 'mailto:'.$enquiry['User']['email'].'?subject='.$enquiry['Enquiry']['title']); ?> -(link($enquiry['User']['email'], 'mailto:'.$enquiry['User']['email'].'?subject='.$enquiry['Enquiry']['title']); ?>).

+ (link($enquiry['User']['email'], 'mailto:'.$enquiry['User']['email'].'?subject='.$enquiry['Enquiry']['title']); ?>).

Sincerely,