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

store unencrypted size in the unencrypted_size column #31966

Merged
merged 3 commits into from
Jun 13, 2022
Merged

Conversation

icewind1991
Copy link
Member

@icewind1991 icewind1991 commented Apr 13, 2022

The column is right there

Store the unencrypted size in the unencrypted_size column instead of the size column, fixes some issues where other code (object storage) stores the encrypted size in the cache.

@icewind1991 icewind1991 added the 2. developing Work in progress label Apr 13, 2022
@icewind1991 icewind1991 force-pushed the unencrypted-size branch 5 times, most recently from 6dd55d3 to ab499e8 Compare April 20, 2022 12:44
@blizzz blizzz added this to the Nextcloud 25 milestone Apr 21, 2022
@icewind1991 icewind1991 force-pushed the unencrypted-size branch 2 times, most recently from 075c050 to 9467d9e Compare April 22, 2022 12:16
@icewind1991 icewind1991 added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Apr 22, 2022
@icewind1991 icewind1991 requested review from a team, ArtificialOwl, CarlSchwan and vanpertsch and removed request for a team April 22, 2022 12:19
@icewind1991
Copy link
Member Author

To test:

  • setup instance with s3 primary storage
  • enable encryption
  • upload some files, verify that the listed size is correct
  • verify that the files can be downloaded a few times and the size stays correct
  • keep an eye out for things exploding :)

Copy link
Member

@CarlSchwan CarlSchwan left a comment

Choose a reason for hiding this comment

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

Code looks 👍

Just some minor comments that can be ignored

lib/public/Files/Cache/ICacheEntry.php Outdated Show resolved Hide resolved
lib/private/Files/Storage/Wrapper/Encryption.php Outdated Show resolved Hide resolved
lib/private/Files/Storage/Wrapper/Encryption.php Outdated Show resolved Hide resolved
@PVince81
Copy link
Member

PVince81 commented Apr 25, 2022

as discussed in chat:

  • check if/how unencrypted_size must be propagated like size, which means it will exist on folders and might affect the logic that detects "-1" sizes in some scenarios

@icewind1991 icewind1991 force-pushed the unencrypted-size branch 3 times, most recently from 8f2d1f6 to 18ce8ec Compare April 28, 2022 13:31
@icewind1991 icewind1991 added 2. developing Work in progress and removed 3. to review Waiting for reviews labels Apr 28, 2022
@icewind1991 icewind1991 force-pushed the unencrypted-size branch 3 times, most recently from 526afc2 to 44a1b35 Compare April 28, 2022 14:13
@come-nc come-nc removed their request for review May 5, 2022 14:59
$x = $this->helper->quoteColumnName($x);
$y = $this->helper->quoteColumnName($y);
return $this->expressionBuilder->comparison($x, $operator, $y);
return new QueryFunction($this->expressionBuilder->comparison($x, $operator, $y));
Copy link
Member

Choose a reason for hiding this comment

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

is this a public API change?

would need to be mentionned in #32117

Copy link
Member

Choose a reason for hiding this comment

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

@icewind1991 can you clarify ?

Copy link
Member Author

Choose a reason for hiding this comment

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

In guess so strictly speaking, but the result here only really gets used by other query builder parts so no app should care about the actual type

Copy link
Contributor

@summersab summersab May 30, 2022

Choose a reason for hiding this comment

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

I applied this PR to my (somewhat customized) Docker image that I am developing. It worked just fine a few days ago, but when I ran it just now, it threw the following error upon trying to access the root page:

{
  "reqId": "EIZn0TU6px16gqETseAb",
  "level": 3,
  "time": "2022-05-30T00:09:52+00:00",
  "remoteAddr": "192.168.0.202",
  "user": "--",
  "app": "PHP",
  "method": "GET",
  "url": "/",
  "message": "Declaration of OC\\DB\\QueryBuilder\\ExpressionBuilder\\ExpressionBuilder::comparison($x, string $operator, $y, $type = null): OCP\\DB\\QueryBuilder\\IQueryFunction must be compatible with OCP\\DB\\QueryBuilder\\IExpressionBuilder::comparison($x, string $operator, $y, $type = null): string at /var/www/html/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php#119",
  "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36",
  "version": "24.0.1.1"
}

I'm fairly adept at debugging Nextcloud and know my way around the code, but this particular PR is quite involved, so I'm not sure where to start to provide more information. Feel free to ask, though - I'm happy to help!

lib/private/Files/Cache/Cache.php Show resolved Hide resolved
@PVince81
Copy link
Member

@icewind1991 some conflicts

this allows passing the expressions to further expressions without them being escaped as column names

Signed-off-by: Robin Appelman <robin@icewind.nl>
Signed-off-by: Robin Appelman <robin@icewind.nl>
Signed-off-by: Robin Appelman <robin@icewind.nl>
Copy link
Member

@PVince81 PVince81 left a comment

Choose a reason for hiding this comment

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

👍

@DaphneMuller
Copy link

@CarlSchwan could you please review this?

@DaphneMuller
Copy link

@szaimen could you please review?

@CarlSchwan CarlSchwan added 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels Jun 13, 2022
@PVince81 PVince81 merged commit 8809de1 into master Jun 13, 2022
@PVince81 PVince81 deleted the unencrypted-size branch June 13, 2022 09:55
@PVince81
Copy link
Member

oh, so the backport got merged before master: #32708

@CarlSchwan
Copy link
Member

This breaks circle

Return value of OCA\Circles\Tools\Db\ExtendedQueryBuilder::exprLimit() must be of the type string, object returned
Fichier : /var/www/html/apps-extra/circles/lib/Tools/Db/ExtendedQueryBuilder.php

@PVince81
Copy link
Member

@icewind1991 can you communicate the API change somehow and put it in #32117

@CarlSchwan
Copy link
Member

nextcloud/circles#1052

@ChristophWurst
Copy link
Member

ChristophWurst commented Jun 13, 2022

This also breaks the Mail app
TypeError: OCA\Mail\Db\MailboxMapper::eqOrNull(): Return value must be of type string, OC\DB\QueryBuilder\QueryFunction returned at https://github.com/nextcloud/mail/blob/f1f4a287ce3b2074759ef959f42af1639ab4daa6/lib/Db/MailboxMapper.php#L214-L226

So yeah, this is a breaking change.

* @since 8.2.0 - Parameter $type was added in 9.0.0
*
* @psalm-taint-sink sql $x
* @psalm-taint-sink sql $y
* @psalm-taint-sink sql $type
*/
public function eq($x, $y, $type = null): string;
public function eq($x, $y, $type = null): IQueryFunction;
Copy link
Member

Choose a reason for hiding this comment

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

from a naming perspective this should have been something like an IExpression

@icewind1991
Copy link
Member Author

Given the unexpected breakage I guess reverting this and using the more "minimal" version from #32708 instead.

@icewind1991
Copy link
Member Author

#32943

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4. to release Ready to be released and/or waiting for tests to finish
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants