Merge pull request #22778 from nextcloud/backport/22739/stable19
[stable19] Don't fail if copying a file of 0 byte size
This commit is contained in:
commit
d43eeab39d
|
@ -51,6 +51,7 @@ use OCP\Encryption\Exceptions\GenericEncryptionException;
|
|||
use OCP\Files\EntityTooLargeException;
|
||||
use OCP\Files\FileInfo;
|
||||
use OCP\Files\ForbiddenException;
|
||||
use OCP\Files\GenericFileException;
|
||||
use OCP\Files\InvalidContentException;
|
||||
use OCP\Files\InvalidPathException;
|
||||
use OCP\Files\LockNotAcquiredException;
|
||||
|
@ -199,8 +200,14 @@ class File extends Node implements IFile {
|
|||
$isEOF = feof($stream);
|
||||
});
|
||||
|
||||
$count = $partStorage->writeStream($internalPartPath, $wrappedData);
|
||||
$result = $count > 0;
|
||||
$result = true;
|
||||
$count = -1;
|
||||
try {
|
||||
$count = $partStorage->writeStream($internalPartPath, $wrappedData);
|
||||
} catch (GenericFileException $e) {
|
||||
$result = false;
|
||||
}
|
||||
|
||||
|
||||
if ($result === false) {
|
||||
$result = $isEOF;
|
||||
|
|
|
@ -26,6 +26,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCP\Files\Storage;
|
||||
|
||||
use OCP\Files\GenericFileException;
|
||||
|
||||
/**
|
||||
* Interface that adds the ability to write a stream directly to file
|
||||
*
|
||||
|
@ -39,6 +41,7 @@ interface IWriteStreamStorage extends IStorage {
|
|||
* @param resource $stream
|
||||
* @param int|null $size the size of the stream if known in advance
|
||||
* @return int the number of bytes written
|
||||
* @throws GenericFileException
|
||||
* @since 15.0.0
|
||||
*/
|
||||
public function writeStream(string $path, $stream, int $size = null): int;
|
||||
|
|
Loading…
Reference in New Issue