diff options
author | Florian Pritz <bluewind@xinu.at> | 2018-07-18 19:39:40 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2018-07-18 19:39:40 +0200 |
commit | 95e600519a98e593540e6ed41570e4915dba862a (patch) | |
tree | e16569ea850be96355326deffa68d8ffc75b1423 /application/service | |
parent | fdc375e9c503e9cb7bdb4754ad5cc9edc64e0220 (diff) |
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 <bluewind@xinu.at>
Diffstat (limited to 'application/service')
-rw-r--r-- | application/service/files.php | 2 |
1 files changed, 2 insertions, 0 deletions
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) |