Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F804010
D321.id808.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Feb 26, 9:03 AM
Size
2 KB
Mime Type
text/x-diff
Expires
Thu, Feb 27, 9:03 AM (1 h, 36 s)
Engine
blob
Format
Raw Data
Handle
576727
Attached To
D321: INP-1719 - Only resize fully uploaded file
D321.id808.diff
View Options
Index: core/units/helpers/upload_helper.php
===================================================================
--- core/units/helpers/upload_helper.php
+++ core/units/helpers/upload_helper.php
@@ -88,9 +88,11 @@
$filename = $this->fileHelper->ensureUniqueFilename($tmp_path, $filename);
$storage_format = $this->getStorageFormat($this->Application->GetVar('field'), $event);
- $this->moveUploadedFile($tmp_path . $filename);
- if ( $storage_format ) {
+ $file_path = $tmp_path . $filename;
+ $actual_file_path = $this->moveUploadedFile($file_path);
+
+ if ( $storage_format && $file_path == $actual_file_path ) {
$this->resizeUploadedFile($tmp_path . $filename, $storage_format);
}
@@ -233,17 +235,18 @@
*
* @param string $file_path File path.
*
- * @return void
+ * @return string
* @throws kUploaderException When upload could not be handled properly.
*/
protected function moveUploadedFile($file_path)
{
- // Chunking might be enabled
+ // Chunking might be enabled.
$chunk = (int)$this->Application->GetVar('chunk', 0);
$chunks = (int)$this->Application->GetVar('chunks', 0);
+ $actual_file_path = $file_path . '.part';
- // Open temp file
- if ( !$out = @fopen("{$file_path}.part", $chunks ? 'ab' : 'wb') ) {
+ // Open temp file.
+ if ( !$out = @fopen($actual_file_path, $chunks ? 'ab' : 'wb') ) {
throw new kUploaderException('Failed to open output stream.', 102);
}
@@ -252,7 +255,7 @@
throw new kUploaderException('Failed to move uploaded file.', 103);
}
- // Read binary input stream and append it to temp file
+ // Read binary input stream and append it to temp file.
if ( !$in = @fopen($_FILES['file']['tmp_name'], 'rb') ) {
throw new kUploaderException('Failed to open input stream.', 101);
}
@@ -270,11 +273,14 @@
@fclose($out);
@fclose($in);
- // Check if file has been uploaded
+ // Check if file has been uploaded.
if ( !$chunks || $chunk == $chunks - 1 ) {
- // Strip the temp .part suffix off
- rename("{$file_path}.part", $file_path);
+ // Strip the temp .part suffix off.
+ rename($actual_file_path, $file_path);
+ $actual_file_path = $file_path;
}
+
+ return $actual_file_path;
}
/**
Event Timeline
Log In to Comment