Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/backup.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Petry <vincent@nextcloud.com>2022-08-25 18:35:12 +0300
committerGitHub <noreply@github.com>2022-08-25 18:35:12 +0300
commitb3bb011a868f7ee9d9f0c55c20c01c4974ac2748 (patch)
tree2a7ce43b5828d4ebd7ac2327353a9ca3ef30ec78
parent1ad7bae5f9a8182742ffb2bded8a0259716ec64d (diff)
parent04fe0a15930c710716b0cf004b25140035c392e1 (diff)
Merge pull request #397 from nextcloud/fix/noid/fix-upload
better upload
-rw-r--r--lib/Service/ExternalFolderService.php13
-rw-r--r--lib/Service/PackService.php6
-rw-r--r--lib/Service/PointService.php1
-rw-r--r--lib/Service/UploadService.php1
-rw-r--r--lib/Tools/ActivityPub/NCSignature.php2
-rw-r--r--lib/Tools/Traits/TNCSignatory.php7
6 files changed, 19 insertions, 11 deletions
diff --git a/lib/Service/ExternalFolderService.php b/lib/Service/ExternalFolderService.php
index a8f614b..231c0e4 100644
--- a/lib/Service/ExternalFolderService.php
+++ b/lib/Service/ExternalFolderService.php
@@ -259,8 +259,7 @@ class ExternalFolderService {
RestoringChunkPart $part
): void {
$folder = $this->getExternalChunkFolder($external, $point, $chunk, true);
- $file = $folder->newFile($part->getName(), '');
- $file->putContent(base64_decode($part->getContent()));
+ $folder->newFile($part->getName(), base64_decode($part->getContent()));
$this->updateChunkPartHealth($external, $point, $health, $chunk, $part);
}
@@ -520,6 +519,9 @@ class ExternalFolderService {
$folder = $this->getExternalPointFolder($external, $point->getId());
try {
$metadataFile = $folder->get(MetadataService::METADATA_FILE);
+ if (!$metadataFile instanceof File) {
+ throw new MetadataException('metadata file is a folder');
+ }
} catch (NotFoundException $e) {
if (!$create) {
throw new MetadataException('metadata file not found');
@@ -700,9 +702,6 @@ class ExternalFolderService {
/** @var File $file */
$file = $folder->get($part->getName());
$stream = $file->fopen('rb');
-// */
-// $file->
-// $stream = $file->();
}
} catch (Exception $e) {
throw new ArchiveNotFoundException(
@@ -790,6 +789,10 @@ class ExternalFolderService {
$folder = $sub;
}
+
+ return $folder;
+
+ // not sure this is useful in the end.
if (!$pack) {
return $folder;
}
diff --git a/lib/Service/PackService.php b/lib/Service/PackService.php
index 1b940ce..053f2a7 100644
--- a/lib/Service/PackService.php
+++ b/lib/Service/PackService.php
@@ -497,11 +497,11 @@ class PackService {
*/
private function wrapStoreParts(RestoringPoint $point, RestoringChunk $chunk, array $parts): void {
try {
- $this->o(' - storing parts in appdata ', false);
+ $this->o(' - storing parts in appdata', false);
$this->storeParts($point, $chunk, $parts);
- $this->o('<info>ok</info>');
+ $this->o(' <info>ok</info>');
} catch (Throwable $t) {
- $this->o('<error>fail ' . $t->getMessage() . '</error>');
+ $this->o(' <error>fail ' . $t->getMessage() . '</error>');
foreach ($parts as $item) {
try {
unlink($item->getName());
diff --git a/lib/Service/PointService.php b/lib/Service/PointService.php
index af57e19..92f9554 100644
--- a/lib/Service/PointService.php
+++ b/lib/Service/PointService.php
@@ -913,6 +913,7 @@ class PointService {
try {
$this->remoteStreamService->verifyPoint($item);
} catch (SignatoryException | SignatureException $e) {
+ $this->e($e);
$this->o(' <error>! cannot confirm integrity</error>');
$issue = 'cannot confirm integrity';
}
diff --git a/lib/Service/UploadService.php b/lib/Service/UploadService.php
index 5ec1cf0..29905c0 100644
--- a/lib/Service/UploadService.php
+++ b/lib/Service/UploadService.php
@@ -426,6 +426,7 @@ class UploadService {
NotPermittedException |
LockedException $e) {
$this->o('<error>' . get_class($e) . ' ' . $e->getMessage() . '</error>');
+ $this->e($e);
}
}
}
diff --git a/lib/Tools/ActivityPub/NCSignature.php b/lib/Tools/ActivityPub/NCSignature.php
index a6a4bf0..d219867 100644
--- a/lib/Tools/ActivityPub/NCSignature.php
+++ b/lib/Tools/ActivityPub/NCSignature.php
@@ -282,7 +282,7 @@ class NCSignature {
try {
$this->verifyString(
$signedRequest->getClearSignature(),
- base64_decode($signedRequest->getSignedSignature()),
+ $signedRequest->getSignedSignature(),
$publicKey,
$this->getUsedEncryption($signedRequest)
);
diff --git a/lib/Tools/Traits/TNCSignatory.php b/lib/Tools/Traits/TNCSignatory.php
index 18b1150..4324e47 100644
--- a/lib/Tools/Traits/TNCSignatory.php
+++ b/lib/Tools/Traits/TNCSignatory.php
@@ -212,9 +212,12 @@ trait TNCSignatory {
* @throws SignatureException
*/
public function verifyString(
- string $clear, string $signed, string $publicKey, string $algo = NCSignatory::SHA256
+ string $clear,
+ string $signed,
+ string $publicKey,
+ string $algo = NCSignatory::SHA256
) {
- if (openssl_verify($clear, $signed, $publicKey, $algo) !== 1) {
+ if (openssl_verify($clear, base64_decode($signed), $publicKey, $algo) !== 1) {
throw new SignatureException('signature issue');
}
}