Skip to content

Commit 0e20d9e

Browse files
authored
Merge pull request #52937 from nextcloud/fix/s3-versions³
fix(files_versions): only close stream if still open, fixing S3
2 parents b9983cb + 2dcadd2 commit 0e20d9e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

apps/files_versions/lib/Storage.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,11 +430,17 @@ private static function copyFileContents($view, $path1, $path2) {
430430
} else {
431431
$target = $storage2->fopen($internalPath2, 'w');
432432
$result = $target !== false;
433-
if ($target !== false) {
433+
if ($result) {
434434
[, $result] = Files::streamCopy($source, $target, true);
435+
}
436+
// explicit check as S3 library closes streams already
437+
if (is_resource($target)) {
435438
fclose($target);
436439
}
437440
}
441+
}
442+
// explicit check as S3 library closes streams already
443+
if (is_resource($source)) {
438444
fclose($source);
439445
}
440446

0 commit comments

Comments
 (0)