diff options
author | Florian Pritz <bluewind@xinu.at> | 2015-02-15 16:26:00 +0100 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2015-02-15 16:26:00 +0100 |
commit | d782a261e2b6466348a6dfc040fac24a3937e174 (patch) | |
tree | c82cbbea3a964400b05e8a70dada9e72f3d6d212 /application | |
parent | e458d2129b7443979816c52bf60ed98b6dcd6579 (diff) |
s/file/add_file: make file move atomic
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application')
-rw-r--r-- | application/service/files.php | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/application/service/files.php b/application/service/files.php index e31efacc1..a2aa83c3b 100644 --- a/application/service/files.php +++ b/application/service/files.php @@ -78,9 +78,11 @@ class files { file_exists($dir) || mkdir ($dir); $new_path = $CI->mfile->file($hash); - // TODO: make this operation atomic (move to temp name, then to final) - // the source can be a different file system so this might do a copy - move_uploaded_file($file, $new_path); + $dest = new \service\storage($new_path); + $tmpfile = $dest->begin(); + move_uploaded_file($file, $tmpfile); + $dest->commit(); + $CI->mfile->add_file($hash, $id, $filename); } |