Prevent race condition on thumbnail generation

This commit is contained in:
Kijin Sung 2015-08-17 10:49:12 +09:00
parent 94d43c2b76
commit 4e6d768dab
2 changed files with 6 additions and 8 deletions

View file

@ -829,6 +829,9 @@ class documentItem extends Object
else return $thumbnail_url;
}
// Prevent race condition
FileHandler::writeFile($thumbnail_file, '', 'w');
// Target File
$source_file = null;
$is_tmp_file = false;
@ -906,8 +909,6 @@ class documentItem extends Object
if($is_tmp_file) FileHandler::removeFile($source_file);
// Return its path if a thumbnail is successfully genetated
if($output) return $thumbnail_url;
// Create an empty file not to re-generate the thumbnail
else FileHandler::writeFile($thumbnail_file, '','w');
return;
}