fix(unified-storage): make full path setting optional on get folders (#104757)

This commit is contained in:
Mustafa Sencer Özcan
2025-05-06 16:20:49 +02:00
committed by GitHub
parent fa93b3b74c
commit dc63f8003c
5 changed files with 223 additions and 233 deletions
+4 -17
View File
@@ -353,14 +353,9 @@ func (s *Service) GetLegacy(ctx context.Context, q *folder.GetFolderQuery) (*fol
return f, err
}
func (s *Service) setFullpath(ctx context.Context, f *folder.Folder, user identity.Requester, forceLegacy bool) (*folder.Folder, error) {
func (s *Service) setFullpath(ctx context.Context, f *folder.Folder, forceLegacy bool) (*folder.Folder, error) {
ctx, span := s.tracer.Start(ctx, "folder.setFullpath")
defer span.End()
// #TODO is some kind of intermediate conversion required as is the case with user id where
// it gets parsed using UserIdentifier(). Also is there some kind of validation taking place as
// part of the parsing?
f.CreatedByUID = user.GetUID()
f.UpdatedByUID = user.GetUID()
if f.ParentUID == "" {
return f, nil
@@ -386,15 +381,7 @@ func (s *Service) setFullpath(ctx context.Context, f *folder.Folder, user identi
}
// #TODO revisit setting permissions so that we can centralise the logic for escaping slashes in titles
// Escape forward slashes in the title
escapedSlash := "\\/"
title := strings.ReplaceAll(f.Title, "/", escapedSlash)
f.Fullpath = title
f.FullpathUIDs = f.UID
for _, p := range parents {
pt := strings.ReplaceAll(p.Title, "/", escapedSlash)
f.Fullpath = f.Fullpath + "/" + pt
f.FullpathUIDs = f.FullpathUIDs + "/" + p.UID
}
f.Fullpath, f.FullpathUIDs = computeFullPath(append(parents, f))
return f, nil
}
@@ -573,7 +560,7 @@ func (s *Service) GetSharedWithMe(ctx context.Context, q *folder.GetChildrenQuer
return nil, folder.ErrInternal.Errorf("failed to fetch root folders to which the user has access: %w", err)
}
dedupAvailableNonRootFolders := s.deduplicateAvailableFolders(ctx, availableNonRootFolders, rootFolders, q.OrgID)
dedupAvailableNonRootFolders := s.deduplicateAvailableFolders(ctx, availableNonRootFolders, rootFolders)
s.metrics.sharedWithMeFetchFoldersRequestsDuration.WithLabelValues("success").Observe(time.Since(start).Seconds())
return dedupAvailableNonRootFolders, nil
}
@@ -641,7 +628,7 @@ func (s *Service) getAvailableNonRootFolders(ctx context.Context, q *folder.GetC
return nonRootFolders, nil
}
func (s *Service) deduplicateAvailableFolders(ctx context.Context, folders []*folder.Folder, rootFolders []*folder.FolderReference, orgID int64) []*folder.FolderReference {
func (s *Service) deduplicateAvailableFolders(ctx context.Context, folders []*folder.Folder, rootFolders []*folder.FolderReference) []*folder.FolderReference {
foldersRef := make([]*folder.FolderReference, len(folders))
for i, f := range folders {
foldersRef[i] = f.ToFolderReference()