fix *.part data corruption

Fixed a bug where when a file upload failed, re-uploading the file would cause the uploaded data to be damaged.
This commit is contained in:
zuiwuchang 2025-01-07 10:54:44 +08:00 committed by GitHub
parent 8f721fcb8b
commit 9c10b3973b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1746,7 +1746,7 @@ function ws_images_upload($params, $service)
// file_put_contents('/tmp/plupload.log', "[".date('c')."] ".__FUNCTION__.', '.$fileName.' '.($chunk+1).'/'.$chunks."\n", FILE_APPEND);
// Open temp file
if (!$out = @fopen("{$filePath}.part", $chunks ? "ab" : "wb"))
if (!$out = @fopen("{$filePath}.part", $chunks && $chunk != 0 ? "ab" : "wb"))
{
die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}');
}