Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletions src/Migration/Sources/Appwrite.php
Original file line number Diff line number Diff line change
Expand Up @@ -1471,7 +1471,7 @@ private function exportFileData(File $file): void
// Get the file size
$fileSize = $file->getSize();

if ($end > $fileSize) {
if ($end >= $fileSize) {
$end = $fileSize - 1;
}

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

if ($end > $fileSize) {
if ($end >= $fileSize) {
$end = $fileSize - 1;
}
}
Expand Down Expand Up @@ -1704,8 +1704,8 @@ private function exportDeploymentData(Func $func, array $deployment): void
$responseHeaders
);

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

$size = mb_strlen($file);
$size = strlen($file);

if ($end > $size) {
$end = $size - 1;
Expand All @@ -1737,7 +1737,11 @@ private function exportDeploymentData(Func $func, array $deployment): void
return;
}

$fileSize = $responseHeaders['Content-Length'];
$fileSize = $responseHeaders['content-length'];

if ($end >= $fileSize) {
$end = $fileSize - 1;
}

$deployment = new Deployment(
$deployment['$id'],
Expand Down Expand Up @@ -1772,7 +1776,7 @@ private function exportDeploymentData(Func $func, array $deployment): void
$start += Transfer::STORAGE_MAX_CHUNK_SIZE;
$end += Transfer::STORAGE_MAX_CHUNK_SIZE;

if ($end > $fileSize) {
if ($end >= $fileSize) {
$end = $fileSize - 1;
}
}
Expand Down Expand Up @@ -1920,7 +1924,7 @@ private function exportSiteDeploymentData(Site $site, array $deployment): void
$responseHeaders
);

if (!\array_key_exists('Content-Length', $responseHeaders)) {
if (!\array_key_exists('content-length', $responseHeaders)) {
$file = $this->call(
'GET',
"/sites/{$site->getId()}/deployments/{$deployment['$id']}/download",
Expand All @@ -1929,7 +1933,7 @@ private function exportSiteDeploymentData(Site $site, array $deployment): void
$responseHeaders
);

$size = mb_strlen($file);
$size = strlen($file);

if ($end > $size) {
$end = $size - 1;
Expand All @@ -1951,7 +1955,11 @@ private function exportSiteDeploymentData(Site $site, array $deployment): void
return;
}

$fileSize = $responseHeaders['Content-Length'];
$fileSize = $responseHeaders['content-length'];

if ($end >= $fileSize) {
$end = $fileSize - 1;
}

$siteDeployment = new SiteDeployment(
$deployment['$id'],
Expand Down Expand Up @@ -1982,7 +1990,7 @@ private function exportSiteDeploymentData(Site $site, array $deployment): void
$start += Transfer::STORAGE_MAX_CHUNK_SIZE;
$end += Transfer::STORAGE_MAX_CHUNK_SIZE;

if ($end > $fileSize) {
if ($end >= $fileSize) {
$end = $fileSize - 1;
}
}
Expand Down