Skip to content

Commit 134efdc

Browse files
committed
fix: use consistent end >= fileSize range clamping
1 parent 3190013 commit 134efdc

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/Migration/Sources/Appwrite.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,7 +1471,7 @@ private function exportFileData(File $file): void
14711471
// Get the file size
14721472
$fileSize = $file->getSize();
14731473

1474-
if ($end > $fileSize) {
1474+
if ($end >= $fileSize) {
14751475
$end = $fileSize - 1;
14761476
}
14771477

@@ -1495,7 +1495,7 @@ private function exportFileData(File $file): void
14951495
$start += Transfer::STORAGE_MAX_CHUNK_SIZE;
14961496
$end += Transfer::STORAGE_MAX_CHUNK_SIZE;
14971497

1498-
if ($end > $fileSize) {
1498+
if ($end >= $fileSize) {
14991499
$end = $fileSize - 1;
15001500
}
15011501
}
@@ -1704,7 +1704,7 @@ private function exportDeploymentData(Func $func, array $deployment): void
17041704
$responseHeaders
17051705
);
17061706

1707-
// content-length header was missing, file is less than max buffer size.
1707+
// content-length header missing, file is less than max buffer size
17081708
if (!array_key_exists('content-length', $responseHeaders)) {
17091709
$file = $this->call(
17101710
'GET',
@@ -1739,7 +1739,7 @@ private function exportDeploymentData(Func $func, array $deployment): void
17391739

17401740
$fileSize = $responseHeaders['content-length'];
17411741

1742-
if ($end > $fileSize - 1) {
1742+
if ($end >= $fileSize) {
17431743
$end = $fileSize - 1;
17441744
}
17451745

@@ -1776,7 +1776,7 @@ private function exportDeploymentData(Func $func, array $deployment): void
17761776
$start += Transfer::STORAGE_MAX_CHUNK_SIZE;
17771777
$end += Transfer::STORAGE_MAX_CHUNK_SIZE;
17781778

1779-
if ($end > $fileSize) {
1779+
if ($end >= $fileSize) {
17801780
$end = $fileSize - 1;
17811781
}
17821782
}
@@ -1957,7 +1957,7 @@ private function exportSiteDeploymentData(Site $site, array $deployment): void
19571957

19581958
$fileSize = $responseHeaders['content-length'];
19591959

1960-
if ($end > $fileSize - 1) {
1960+
if ($end >= $fileSize) {
19611961
$end = $fileSize - 1;
19621962
}
19631963

@@ -1990,7 +1990,7 @@ private function exportSiteDeploymentData(Site $site, array $deployment): void
19901990
$start += Transfer::STORAGE_MAX_CHUNK_SIZE;
19911991
$end += Transfer::STORAGE_MAX_CHUNK_SIZE;
19921992

1993-
if ($end > $fileSize) {
1993+
if ($end >= $fileSize) {
19941994
$end = $fileSize - 1;
19951995
}
19961996
}

0 commit comments

Comments
 (0)