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

Add support for Spaces #4404

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

Add support for Spaces #4404

wants to merge 174 commits into from

Conversation

glpatcern
Copy link
Member

@glpatcern glpatcern commented Dec 13, 2023

All credits to @gmgigi96, I reopened this PR so we can keep working on it.

Missing parts:

  • Expose permission to share (currently, the frontend believes the user can't share anything and hides the "shared by me" view)
  • OCS API to support the new storageid format
  • Trashbin support
  • Share hiding/accepting
    A way to enable/disable this format by config, such that we can have the functionality in the code and enable it once ready

And from the last merge:

  • Look into all replaces in go.mod, in particular for the cs3apis

Copy link
Member Author

@glpatcern glpatcern left a comment

Choose a reason for hiding this comment

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

I went for a full review of this branch. Some new code chunks implement the logic required by the LibreGraph API and I considered them "good", trusting the tests we're doing with the web UI. There are a few trivial fixes (already merged) and some other larger changes to be done/discussed.


func (m *mgr) ListProjects(ctx context.Context, user *userpb.User) ([]*provider.StorageSpace, error) {
// TODO: for the time being we load everything in memory. We may find a better
// solution in future when the number of projects will grow.
Copy link
Member Author

Choose a reason for hiding this comment

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

Loading in memory is not a big issue per se, but how are we refreshing this cache as new project spaces get created?

Copy link
Contributor

@diocas diocas Feb 7, 2025

Choose a reason for hiding this comment

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

Is the impact that great to keep getting the data from the DB instead of loading it? Can't we put a cache in front?


Jesse (because for some reason I cannot comment): I created a cache in a new PR: #5094

drive, err := s.cs3ReceivedShareToDriveItem(ctx, share)
if err != nil {
log.Error().Err(err).Msg("error getting received shares")
w.WriteHeader(http.StatusInternalServerError)
Copy link
Member Author

Choose a reason for hiding this comment

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

Let's not accumulate further technical debt with those HTTP 500:

  • On a loop, we should skip and return the rest
  • In the other cases, we should return something relevant for the frontend to show (and help us in debugging afterwards)

jessegeens and others added 5 commits February 3, 2025 10:59
…5053)

Bumps google.golang.org/protobuf from 1.36.1 to 1.36.4.

---
updated-dependencies:
- dependency-name: google.golang.org/protobuf
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…#5049)

Bumps [github.com/coreos/go-oidc/v3](https://github.com/coreos/go-oidc) from 3.11.0 to 3.12.0.
- [Release notes](https://github.com/coreos/go-oidc/releases)
- [Commits](coreos/go-oidc@v3.11.0...v3.12.0)

---
updated-dependencies:
- dependency-name: github.com/coreos/go-oidc/v3
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [go.step.sm/crypto](https://github.com/smallstep/crypto) from 0.55.0 to 0.57.0.
- [Release notes](https://github.com/smallstep/crypto/releases)
- [Commits](smallstep/crypto@v0.55.0...v0.57.0)

---
updated-dependencies:
- dependency-name: go.step.sm/crypto
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@glpatcern glpatcern removed the request for review from a team February 4, 2025 15:18
Copy link
Contributor

@diocas diocas left a comment

Choose a reason for hiding this comment

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

This code could still benefit from (much) more detailed documentation.....
And some functions could be unified in a single place (e.g. things related to converting IDs to strings and reverse).
I would also take the time to go full orm with it.


func (m *mgr) ListProjects(ctx context.Context, user *userpb.User) ([]*provider.StorageSpace, error) {
// TODO: for the time being we load everything in memory. We may find a better
// solution in future when the number of projects will grow.
Copy link
Contributor

@diocas diocas Feb 7, 2025

Choose a reason for hiding this comment

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

Is the impact that great to keep getting the data from the DB instead of loading it? Can't we put a cache in front?


Jesse (because for some reason I cannot comment): I created a cache in a new PR: #5094


spacesRes := make([]*libregraph.Drive, 0, len(res.ShareInfos))
for _, share := range res.ShareInfos {
spacesRes = append(spacesRes, s.convertShareToSpace(share))
Copy link
Contributor

Choose a reason for hiding this comment

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

ListExistingReceivedShares checks if a share is valid (by doing a stat), right? I wonder if we find performance issues if that is necessary. After all, the real shares listing are requested separately, so even if we sent data that is no longer accessible, it wouldn't be a problem.
Either way, to me these mountpoint spaces don't make much sense. It should be 1 space per person that shared, and not by share (since we consider the users' homes the sole spaces). But alas, this would need changes from web.


// For the moment, not supported
func isShareJail(spaceID string) bool {
return false // TODO
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this the hardcoded share jail id we set above?

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it would, but afaik we decided not to support sharejails for now


d := &libregraph.DriveItem{
UIHidden: libregraph.PtrBool(rsi.ReceivedShare.Hidden),
ClientSynchronize: libregraph.PtrBool(true),
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this what we now added in the new share schema?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, and this gets propagated now to the ReceivedShare.Hidden field :)


func groupByResourceID(shares []*gateway.ShareResourceInfo, publicShares []*gateway.PublicShareResourceInfo) (map[string][]*share, map[string]*provider.ResourceInfo) {
grouped := make(map[string][]*share, len(shares)+len(publicShares)) // at most we have the sum of both lists
infos := make(map[string]*provider.ResourceInfo, len(shares)+len(publicShares))
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it for performance reasons that we are allocating the space now?

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess yes, otherwise you get a backing array with a small capacity and have to continually increase the backing array capacity as the map fills up. So if you know the size beforehand it's better to already pass it

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

Successfully merging this pull request may close these issues.

5 participants