From 28065c2ea472f602b73ed21a705f354a09ed102a Mon Sep 17 00:00:00 2001 From: Hugo Renard Date: Thu, 24 Nov 2022 14:12:54 +0100 Subject: [PATCH] fix: revert file version --- base/Dockerfile | 3 +- base/apps/files_versions_s3.patch | 70 +++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 base/apps/files_versions_s3.patch diff --git a/base/Dockerfile b/base/Dockerfile index a887c58..78beebf 100644 --- a/base/Dockerfile +++ b/base/Dockerfile @@ -7,7 +7,8 @@ WORKDIR /apps ARG MINOR_VERSION RUN ./install.sh RUN cd apps/mail && patch -p1 < ../../mail-enumeration-leak.patch -RUN rm ./install.sh ./install-list ./mail-enumeration-leak.patch +RUN cd apps/files_versions_s3 && patch -p1 < ../../files_versions_s3.patch +RUN rm ./install.sh ./install-list ./mail-enumeration-leak.patch ./files_versions_s3.patch FROM nextcloud:${MARKETTING_VERSION}-fpm-alpine ENV VERSION $PATCH_VERSION diff --git a/base/apps/files_versions_s3.patch b/base/apps/files_versions_s3.patch new file mode 100644 index 0000000..54899fa --- /dev/null +++ b/base/apps/files_versions_s3.patch @@ -0,0 +1,70 @@ +diff --git a/lib/Versions/AbstractS3VersionBackend.php b/lib/Versions/AbstractS3VersionBackend.php +index a13e882..4b9d142 100644 +--- a/lib/Versions/AbstractS3VersionBackend.php ++++ b/lib/Versions/AbstractS3VersionBackend.php +@@ -48,7 +48,7 @@ abstract class AbstractS3VersionBackend implements IVersionBackend { + + abstract protected function getUrn(FileInfo $file): string; + +- abstract protected function postRollback(FileInfo $file); ++ abstract protected function postRollback(FileInfo $file, IVersion $version); + + public function getVersionsForFile(IUser $user, FileInfo $file): array { + $s3 = $this->getS3($file); +@@ -68,7 +68,7 @@ abstract class AbstractS3VersionBackend implements IVersionBackend { + $s3 = $this->getS3($source); + if ($s3) { + $this->versionProvider->rollback($s3, $this->getUrn($source), $version->getRevisionId()); +- $this->postRollback($source); ++ $this->postRollback($source, $version); + return true; + } + +diff --git a/lib/Versions/ExternalS3VersionsBackend.php b/lib/Versions/ExternalS3VersionsBackend.php +index 1d2ee00..c92e40c 100644 +--- a/lib/Versions/ExternalS3VersionsBackend.php ++++ b/lib/Versions/ExternalS3VersionsBackend.php +@@ -26,6 +26,7 @@ namespace OCA\FilesVersionsS3\Versions; + use OC\Files\ObjectStore\S3ConnectionTrait; + use OC\Files\Storage\Wrapper\Jail; + use OCA\Files_External\Lib\Storage\AmazonS3; ++use OCA\Files_Versions\Versions\IVersion; + use OCP\Files\FileInfo; + use OCP\Files\Storage\IStorage; + +@@ -59,7 +60,7 @@ class ExternalS3VersionsBackend extends AbstractS3VersionBackend { + return $path; + } + +- protected function postRollback(FileInfo $file) { ++ protected function postRollback(FileInfo $file, IVersion $version) { + $file->getStorage()->getUpdater()->update($file->getInternalPath()); + } + } +diff --git a/lib/Versions/PrimaryS3VersionsBackend.php b/lib/Versions/PrimaryS3VersionsBackend.php +index 7331676..c4eeabc 100644 +--- a/lib/Versions/PrimaryS3VersionsBackend.php ++++ b/lib/Versions/PrimaryS3VersionsBackend.php +@@ -26,6 +26,7 @@ namespace OCA\FilesVersionsS3\Versions; + use OC\Files\ObjectStore\ObjectStoreStorage; + use OC\Files\ObjectStore\S3; + use OC\Files\ObjectStore\S3ConnectionTrait; ++use OCA\Files_Versions\Versions\IVersion; + use OCP\Files\FileInfo; + use OCP\Files\Storage\IStorage; + +@@ -62,11 +63,12 @@ class PrimaryS3VersionsBackend extends AbstractS3VersionBackend { + return $storage->getURN($file->getId()); + } + +- protected function postRollback(FileInfo $file) { ++ protected function postRollback(FileInfo $file, IVersion $version) { + $cache = $file->getStorage()->getCache(); + $cache->update($file->getId(), [ + 'mtime' => time(), +- 'etag' => $file->getStorage()->getETag($file->getInternalPath()) ++ 'etag' => $file->getStorage()->getETag($file->getInternalPath()), ++ 'size' => $version->getSize(), + ]); + } + } -- GitLab