Skip to content

Commit 6817db3

Browse files
committed
Merge branch 'main' of https://github.com/utopia-php/migration into joins
2 parents db744ef + 037bf4b commit 6817db3

1 file changed

Lines changed: 19 additions & 11 deletions

File tree

src/Migration/Sources/Appwrite.php

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,7 +1476,7 @@ private function exportFileData(File $file): void
14761476
// Get the file size
14771477
$fileSize = $file->getSize();
14781478

1479-
if ($end > $fileSize) {
1479+
if ($end >= $fileSize) {
14801480
$end = $fileSize - 1;
14811481
}
14821482

@@ -1500,7 +1500,7 @@ private function exportFileData(File $file): void
15001500
$start += Transfer::STORAGE_MAX_CHUNK_SIZE;
15011501
$end += Transfer::STORAGE_MAX_CHUNK_SIZE;
15021502

1503-
if ($end > $fileSize) {
1503+
if ($end >= $fileSize) {
15041504
$end = $fileSize - 1;
15051505
}
15061506
}
@@ -1709,8 +1709,8 @@ private function exportDeploymentData(Func $func, array $deployment): void
17091709
$responseHeaders
17101710
);
17111711

1712-
// Content-Length header was missing, file is less than max buffer size.
1713-
if (!array_key_exists('Content-Length', $responseHeaders)) {
1712+
// content-length header missing, file is less than max buffer size
1713+
if (!array_key_exists('content-length', $responseHeaders)) {
17141714
$file = $this->call(
17151715
'GET',
17161716
"/functions/{$func->getId()}/deployments/{$deployment['$id']}/download",
@@ -1719,7 +1719,7 @@ private function exportDeploymentData(Func $func, array $deployment): void
17191719
$responseHeaders
17201720
);
17211721

1722-
$size = mb_strlen($file);
1722+
$size = strlen($file);
17231723

17241724
if ($end > $size) {
17251725
$end = $size - 1;
@@ -1742,7 +1742,11 @@ private function exportDeploymentData(Func $func, array $deployment): void
17421742
return;
17431743
}
17441744

1745-
$fileSize = $responseHeaders['Content-Length'];
1745+
$fileSize = $responseHeaders['content-length'];
1746+
1747+
if ($end >= $fileSize) {
1748+
$end = $fileSize - 1;
1749+
}
17461750

17471751
$deployment = new Deployment(
17481752
$deployment['$id'],
@@ -1777,7 +1781,7 @@ private function exportDeploymentData(Func $func, array $deployment): void
17771781
$start += Transfer::STORAGE_MAX_CHUNK_SIZE;
17781782
$end += Transfer::STORAGE_MAX_CHUNK_SIZE;
17791783

1780-
if ($end > $fileSize) {
1784+
if ($end >= $fileSize) {
17811785
$end = $fileSize - 1;
17821786
}
17831787
}
@@ -1925,7 +1929,7 @@ private function exportSiteDeploymentData(Site $site, array $deployment): void
19251929
$responseHeaders
19261930
);
19271931

1928-
if (!\array_key_exists('Content-Length', $responseHeaders)) {
1932+
if (!\array_key_exists('content-length', $responseHeaders)) {
19291933
$file = $this->call(
19301934
'GET',
19311935
"/sites/{$site->getId()}/deployments/{$deployment['$id']}/download",
@@ -1934,7 +1938,7 @@ private function exportSiteDeploymentData(Site $site, array $deployment): void
19341938
$responseHeaders
19351939
);
19361940

1937-
$size = mb_strlen($file);
1941+
$size = strlen($file);
19381942

19391943
if ($end > $size) {
19401944
$end = $size - 1;
@@ -1956,7 +1960,11 @@ private function exportSiteDeploymentData(Site $site, array $deployment): void
19561960
return;
19571961
}
19581962

1959-
$fileSize = $responseHeaders['Content-Length'];
1963+
$fileSize = $responseHeaders['content-length'];
1964+
1965+
if ($end >= $fileSize) {
1966+
$end = $fileSize - 1;
1967+
}
19601968

19611969
$siteDeployment = new SiteDeployment(
19621970
$deployment['$id'],
@@ -1987,7 +1995,7 @@ private function exportSiteDeploymentData(Site $site, array $deployment): void
19871995
$start += Transfer::STORAGE_MAX_CHUNK_SIZE;
19881996
$end += Transfer::STORAGE_MAX_CHUNK_SIZE;
19891997

1990-
if ($end > $fileSize) {
1998+
if ($end >= $fileSize) {
19911999
$end = $fileSize - 1;
19922000
}
19932001
}

0 commit comments

Comments
 (0)