Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(files_versions): Update unencrypted_size during rollback #50299

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

artonge
Copy link
Contributor

@artonge artonge commented Jan 21, 2025

This prevents restored versions of encrypted files from having a wrong reported size. This was blocking download.

@artonge artonge self-assigned this Jan 21, 2025
@artonge artonge added bug 3. to review Waiting for reviews php Pull requests that update Php code labels Jan 21, 2025
@artonge artonge added this to the Nextcloud 31 milestone Jan 21, 2025
@artonge
Copy link
Contributor Author

artonge commented Jan 21, 2025

/backport to stable30

@artonge
Copy link
Contributor Author

artonge commented Jan 21, 2025

/backport to stable29

@artonge
Copy link
Contributor Author

artonge commented Jan 21, 2025

/backport to stable28

This prevent restored version of encrypted files from having a wrong reported size. This was blocking download.

Signed-off-by: Louis Chemineau <[email protected]>
Comment on lines +381 to +382
'size' => $oldFileInfo->getSize(),
'unencrypted_size' => $oldFileInfo->getSize(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But then is that the correct size? If versions are encrypted then size and unencrypted_size should be different, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. getSize() return the unencrypted_size if the file is encrypted:

public function getSize($includeMounts = true) {
if ($includeMounts) {
$this->updateEntryFromSubMounts();
if ($this->isEncrypted() && isset($this->data['unencrypted_size']) && $this->data['unencrypted_size'] > 0) {
return $this->data['unencrypted_size'];
} else {
return isset($this->data['size']) ? 0 + $this->data['size'] : 0;
}
} else {
return $this->rawSize;
}
}

But not sure how to properly get the size, then. Or maybe we should set size or unencrypted_size depending on the encryption status.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, no, if we do that size will not be updated. But not even use size if the file is encrypted

@artonge
Copy link
Contributor Author

artonge commented Jan 23, 2025

/backport to stable31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants