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(Node): Do not drop readonly attributes but only forbid updating them #967

Merged
merged 2 commits into from
May 29, 2024

Conversation

susnux
Copy link
Contributor

@susnux susnux commented May 29, 2024

Attributes that are readonly should still be listed in the attributes getter, otherwise this is a hard breaking change as a lot of apps already depend on attributes. So instead only ensure that readonly attributes are skipped by the proxy handler.

@susnux susnux added bug Something isn't working 3. to review labels May 29, 2024
@susnux susnux requested review from skjnldsv and ShGKme May 29, 2024 08:08
Copy link

codecov bot commented May 29, 2024

Bundle Report

Changes will increase total bundle size by 1.97kB ⬆️

Bundle name Size Change
@nextcloud/files-esm 109.83kB 987 bytes ⬆️
@nextcloud/files-esm-cjs 110.86kB 110.86kB ⬆️
@nextcloud/files-cjs (removed) 109.87kB ⬇️

@susnux
Copy link
Contributor Author

susnux commented May 29, 2024

See error when upgrading files on server (and we need to backport to 29 and 28!):
nextcloud/server#45538

Attributes that are readonly should still be listed in the `attributes` getter,
otherwise this is a hard breaking change as a lot of apps already depend on `attributes`.
So instead only ensure that readonly attributes are skipped by the proxy handler.

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
@susnux susnux force-pushed the fix/do-not-remove-attributes branch from 13eb986 to 4a7ece4 Compare May 29, 2024 08:24
@susnux susnux requested review from artonge and Pytal May 29, 2024 10:52
Copy link
Contributor

@skjnldsv skjnldsv left a comment

Choose a reason for hiding this comment

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

I disagree, why do you use the attributes.size ?
That is the issue in the first place, no?

@susnux
Copy link
Contributor Author

susnux commented May 29, 2024

I disagree, why do you use the attributes.size ?
That is the issue in the first place, no?

It was never documented to not use attributes for size or basename so removing them from attributes breaks the API.
So removing attributes was a breaking change that needs to be reverted or like here to be fixed.

We can branch off if you like and spin up a new major for the removed attributes, but I think in general it makes more sense to keep the attributes and just make them readonly (like I did here).

@susnux susnux force-pushed the fix/do-not-remove-attributes branch 2 times, most recently from f1142dc to f11ad8c Compare May 29, 2024 16:36
…gh Node.attributes

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
@susnux susnux force-pushed the fix/do-not-remove-attributes branch from f11ad8c to 12b6dcc Compare May 29, 2024 16:46
@susnux
Copy link
Contributor Author

susnux commented May 29, 2024

Added a test case to prevent doing:

file.attributes.owner = 'foo'

As this is also protected

@susnux susnux merged commit b32e636 into main May 29, 2024
14 checks passed
@susnux susnux deleted the fix/do-not-remove-attributes branch May 29, 2024 16:48
Comment on lines +358 to +371
for (const [name, value] of Object.entries(attributes)) {
try {
if (value === undefined) {
delete this.attributes[name]
} else {
this.attributes[name] = value
}
} catch (e) {
// Ignore readonly attributes
if (e instanceof TypeError) {
continue
}
// Throw all other exceptions
throw e
Copy link
Contributor

Choose a reason for hiding this comment

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

One drawback of this, now there is no way to update ll attributes without updating the mtime :/
That was one of the feature I added and needed from #947 😅 @susnux

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, you can't remove attributes anymore (unless you know they exist on the node already)

Copy link
Contributor

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants