Skip to content

Commit

Permalink
remove creation of .space folder (#2519)
Browse files Browse the repository at this point in the history
* remove creation of .space folder

* fix unit tests

* fix integration tests
  • Loading branch information
micbar authored and butonic committed Feb 14, 2022
1 parent 68080f0 commit 4c185f9
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 33 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/remove-dot-space.md
Original file line number Diff line number Diff line change
@@ -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
17 changes: 0 additions & 17 deletions pkg/storage/utils/decomposedfs/spaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -504,19 +500,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 {
Expand Down
19 changes: 7 additions & 12 deletions pkg/storage/utils/decomposedfs/upload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
})
})

Expand All @@ -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))
})
})

Expand Down Expand Up @@ -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))
})
})

Expand Down Expand Up @@ -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))
})
})

Expand All @@ -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))
})
})

Expand Down
6 changes: 3 additions & 3 deletions tests/integration/grpc/gateway_storageprovider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"}))
})

})
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/grpc/storageprovider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 4c185f9

Please sign in to comment.