From 95e600519a98e593540e6ed41570e4915dba862a Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Wed, 18 Jul 2018 19:39:40 +0200 Subject: Use transaction when adding file This helps when the upload_path is not writable. Without the transaction we get stale records in the db that then cause errors because the file can't be found. Signed-off-by: Florian Pritz --- application/service/files.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/application/service/files.php b/application/service/files.php index 3cdb1ff22..a98e0873f 100644 --- a/application/service/files.php +++ b/application/service/files.php @@ -150,6 +150,7 @@ class files { $hash = md5_file($new_file); $storage_id = null; + $CI->db->trans_start(); $query = $CI->db->select('id, hash') ->from('file_storage') ->where('hash', $hash) @@ -203,6 +204,7 @@ class files { } $CI->mfile->add_file($userid, $id, $filename, $storage_id); + $CI->db->trans_complete(); } static public function verify_uploaded_files($files) -- cgit v1.2.3-24-g4f1b