Skip to content

Commit

Permalink
Fix Encryption Wrapper
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
  • Loading branch information
skjnldsv committed Nov 4, 2021
1 parent 704760a commit f93bb7d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions lib/private/Files/Storage/Wrapper/Encryption.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function __construct(
* The result for filesize when called on a folder is required to be 0
*
* @param string $path
* @return int
* @return int|bool
*/
public function filesize($path) {
$fullPath = $this->getFullPath($path);
Expand Down Expand Up @@ -209,7 +209,7 @@ public function getDirectoryContent($directory): \Traversable {
* see http://php.net/manual/en/function.file_get_contents.php
*
* @param string $path
* @return string
* @return string|bool
*/
public function file_get_contents($path) {
$encryptionModule = $this->getEncryptionModule($path);
Expand Down Expand Up @@ -402,6 +402,7 @@ public function fopen($path, $mode) {

if ($this->file_exists($path)) {
$size = $this->storage->filesize($path);
/** @var int */
$unencryptedSize = $this->filesize($path);
} else {
$size = $unencryptedSize = 0;
Expand Down Expand Up @@ -498,7 +499,7 @@ protected function verifyUnencryptedSize($path, $unencryptedSize) {
if (isset($this->fixUnencryptedSizeOf[$this->getFullPath($path)]) === false) {
$this->fixUnencryptedSizeOf[$this->getFullPath($path)] = true;
try {
$result = $this->fixUnencryptedSize($path, $size, $unencryptedSize);
$result = $this->fixUnencryptedSize($path, (int) $size, $unencryptedSize);
} catch (\Exception $e) {
$this->logger->error('Couldn\'t re-calculate unencrypted size for ' . $path);
$this->logger->logException($e);
Expand Down Expand Up @@ -760,7 +761,7 @@ private function copyBetweenStorage(Storage\IStorage $sourceStorage, $sourceInte
}
if ($result) {
if ($preserveMtime) {
$this->touch($targetInternalPath, $sourceStorage->filemtime($sourceInternalPath));
$this->touch($targetInternalPath, (int) $sourceStorage->filemtime($sourceInternalPath));
}
$this->updateEncryptedVersion($sourceStorage, $sourceInternalPath, $targetInternalPath, $isRename, false);
} else {
Expand All @@ -778,7 +779,7 @@ private function copyBetweenStorage(Storage\IStorage $sourceStorage, $sourceInte
* The local version of the file can be temporary and doesn't have to be persistent across requests
*
* @param string $path
* @return string
* @return bool|string
*/
public function getLocalFile($path) {
if ($this->encryptionManager->isEnabled()) {
Expand Down Expand Up @@ -807,7 +808,7 @@ public function isLocal() {
* only the following keys are required in the result: size and mtime
*
* @param string $path
* @return array
* @return array|bool
*/
public function stat($path) {
$stat = $this->storage->stat($path);
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Files/Stream/Encryption.php
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ protected function readCache() {
/**
* write header at beginning of encrypted file
*
* @return integer
* @return int|false
* @throws EncryptionHeaderKeyExistsException if header key is already in use
*/
protected function writeHeader() {
Expand Down

0 comments on commit f93bb7d

Please sign in to comment.