From 0814d2f50559793cf2cba8058c93130b26d126e6 Mon Sep 17 00:00:00 2001 From: Michael Barz Date: Tue, 8 Feb 2022 14:17:16 +0100 Subject: [PATCH] remove creation of .space folder (#2519) * remove creation of .space folder * fix unit tests * fix integration tests --- changelog/unreleased/remove-dot-space.md | 5 +++++ pkg/storage/utils/decomposedfs/spaces.go | 17 ----------------- pkg/storage/utils/decomposedfs/upload_test.go | 19 +++++++------------ .../grpc/gateway_storageprovider_test.go | 6 +++--- .../integration/grpc/storageprovider_test.go | 2 +- 5 files changed, 16 insertions(+), 33 deletions(-) create mode 100644 changelog/unreleased/remove-dot-space.md diff --git a/changelog/unreleased/remove-dot-space.md b/changelog/unreleased/remove-dot-space.md new file mode 100644 index 0000000000..fb69cac1ea --- /dev/null +++ b/changelog/unreleased/remove-dot-space.md @@ -0,0 +1,5 @@ +Change: remove the auto creation of the .space folder + +We removed the auto creation of the .space folder because we don't develop this feature further. + +https://github.com/cs3org/reva/pull/2519 diff --git a/pkg/storage/utils/decomposedfs/spaces.go b/pkg/storage/utils/decomposedfs/spaces.go index 1a6bcee6b5..d26a358107 100644 --- a/pkg/storage/utils/decomposedfs/spaces.go +++ b/pkg/storage/utils/decomposedfs/spaces.go @@ -99,10 +99,6 @@ func (fs *Decomposedfs) CreateStorageSpace(ctx context.Context, req *provider.Cr return nil, err } - if err := fs.createHiddenSpaceFolder(ctx, n); err != nil { - return nil, err - } - u, ok := ctxpkg.ContextGetUser(ctx) if !ok { return nil, fmt.Errorf("decomposedfs: spaces: contextual user not found") @@ -498,19 +494,6 @@ func (fs *Decomposedfs) DeleteStorageSpace(ctx context.Context, req *provider.De return os.Symlink(trashPath, np) } -// createHiddenSpaceFolder bootstraps a storage space root with a hidden ".space" folder used to store space related -// metadata such as a description or an image. -// Internally createHiddenSpaceFolder leverages the use of node.Child() to create a new node under the space root. -// createHiddenSpaceFolder is just a contextual alias for node.Child() for ".spaces". -func (fs *Decomposedfs) createHiddenSpaceFolder(ctx context.Context, r *node.Node) error { - hiddenSpace, err := r.Child(ctx, ".space") - if err != nil { - return err - } - - return fs.tp.CreateDir(ctx, hiddenSpace) -} - func (fs *Decomposedfs) createStorageSpace(ctx context.Context, spaceType, spaceID string) error { // create space type dir if err := os.MkdirAll(filepath.Join(fs.o.Root, "spaces", spaceType), 0700); err != nil { diff --git a/pkg/storage/utils/decomposedfs/upload_test.go b/pkg/storage/utils/decomposedfs/upload_test.go index 1ad307b18f..1db9dc21ab 100644 --- a/pkg/storage/utils/decomposedfs/upload_test.go +++ b/pkg/storage/utils/decomposedfs/upload_test.go @@ -189,8 +189,7 @@ var _ = Describe("File uploads", func() { resources, err := fs.ListFolder(ctx, rootRef, []string{}) Expect(err).ToNot(HaveOccurred()) - Expect(len(resources)).To(Equal(1)) // .space folder - Expect(resources[0].Path).To(Equal("/.space")) + Expect(len(resources)).To(Equal(0)) }) }) @@ -206,8 +205,7 @@ var _ = Describe("File uploads", func() { resources, err := fs.ListFolder(ctx, rootRef, []string{}) Expect(err).ToNot(HaveOccurred()) - Expect(len(resources)).To(Equal(1)) // .space folder - Expect(resources[0].Path).To(Equal("/.space")) + Expect(len(resources)).To(Equal(0)) }) }) @@ -244,9 +242,8 @@ var _ = Describe("File uploads", func() { resources, err := fs.ListFolder(ctx, rootRef, []string{}) Expect(err).ToNot(HaveOccurred()) - Expect(len(resources)).To(Equal(2)) // .space folder & uploaded resource - Expect(resources[0].Path).To(Or(Equal(ref.Path), Equal("/.space"))) - Expect(resources[1].Path).To(Or(Equal(ref.Path), Equal("/.space"))) + Expect(len(resources)).To(Equal(1)) + Expect(resources[0].Path).To(Equal(ref.Path)) }) }) @@ -283,9 +280,8 @@ var _ = Describe("File uploads", func() { resources, err := fs.ListFolder(ctx, rootRef, []string{}) Expect(err).ToNot(HaveOccurred()) - Expect(len(resources)).To(Equal(2)) // .space folder & uploaded file - Expect(resources[0].Path).To(Or(Equal(ref.Path), Equal("/.space"))) - Expect(resources[1].Path).To(Or(Equal(ref.Path), Equal("/.space"))) + Expect(len(resources)).To(Equal(1)) + Expect(resources[0].Path).To(Equal(ref.Path)) }) }) @@ -303,8 +299,7 @@ var _ = Describe("File uploads", func() { resources, err := fs.ListFolder(ctx, rootRef, []string{}) Expect(err).ToNot(HaveOccurred()) - Expect(len(resources)).To(Equal(1)) // .space folder - Expect(resources[0].Path).To(Equal("/.space")) + Expect(len(resources)).To(Equal(0)) }) }) diff --git a/tests/integration/grpc/gateway_storageprovider_test.go b/tests/integration/grpc/gateway_storageprovider_test.go index 2fac29bdc1..af7df5ec76 100644 --- a/tests/integration/grpc/gateway_storageprovider_test.go +++ b/tests/integration/grpc/gateway_storageprovider_test.go @@ -334,12 +334,12 @@ var _ = Describe("gateway", func() { listRes, err = serviceClient.ListContainer(ctx, &storagep.ListContainerRequest{Ref: &storagep.Reference{ResourceId: shard1Space.Root, Path: "."}}) Expect(err).ToNot(HaveOccurred()) Expect(listRes.Status.Code).To(Equal(rpcv1beta1.Code_CODE_OK)) - Expect(len(listRes.Infos)).To(Equal(2)) + Expect(len(listRes.Infos)).To(Equal(1)) paths := []string{} for _, i := range listRes.Infos { paths = append(paths, i.Path) } - Expect(paths).To(ConsistOf([]string{"file.txt", ".space"})) + Expect(paths).To(ConsistOf([]string{"file.txt"})) }) }) @@ -429,7 +429,7 @@ var _ = Describe("gateway", func() { listRes, err := serviceClient.ListContainer(ctx, &storagep.ListContainerRequest{Ref: homeRef}) Expect(err).ToNot(HaveOccurred()) Expect(listRes.Status.Code).To(Equal(rpcv1beta1.Code_CODE_OK)) - Expect(len(listRes.Infos)).To(Equal(2)) + Expect(len(listRes.Infos)).To(Equal(1)) var fileInfo *storagep.ResourceInfo // var embeddedInfo *storagep.ResourceInfo diff --git a/tests/integration/grpc/storageprovider_test.go b/tests/integration/grpc/storageprovider_test.go index 2b005eaec5..8f9af283f1 100644 --- a/tests/integration/grpc/storageprovider_test.go +++ b/tests/integration/grpc/storageprovider_test.go @@ -175,7 +175,7 @@ var _ = Describe("storage providers", func() { switch provider { case "ocis": - Expect(len(listRes.Infos)).To(Equal(2)) // subdir + .space + Expect(len(listRes.Infos)).To(Equal(1)) // subdir case "nextcloud": Expect(len(listRes.Infos)).To(Equal(1)) // subdir default: