Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

Commit

Permalink
Create dir (#45)
Browse files Browse the repository at this point in the history
* Implement GSP-93: Add ObjectMode Pair

* add direr test

* update Create with objectMode
  • Loading branch information
JinnyYi authored Jun 11, 2021
1 parent 8cff599 commit fa77bdb
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 26 deletions.
77 changes: 66 additions & 11 deletions generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/beyondstorage/go-service-fs/v3
go 1.15

require (
github.com/beyondstorage/go-integration-test/v4 v4.0.0
github.com/beyondstorage/go-storage/v4 v4.0.1-0.20210530044854-1c928ddbe52d
github.com/beyondstorage/go-integration-test/v4 v4.1.0
github.com/beyondstorage/go-storage/v4 v4.1.0
github.com/qingstor/go-mime v0.1.0
github.com/stretchr/testify v1.7.0
golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7
Expand Down
18 changes: 8 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
github.com/Xuanwo/templateutils v0.1.0 h1:WpkWOqQtIQ2vAIpJLa727DdN8WtxhUkkbDGa6UhntJY=
github.com/Xuanwo/templateutils v0.1.0/go.mod h1:OdE0DJ+CJxDBq6psX5DPV+gOZi8bhuHuVUpPCG++Wb8=
github.com/beyondstorage/go-integration-test/v4 v4.0.0 h1:tdXQV9yxQ3Q6p9xfyQKzK3MEo9r9j9g3uT5+3sbVtnQ=
github.com/beyondstorage/go-integration-test/v4 v4.0.0/go.mod h1:26/JF4b0XxRN0pL4kihpnVNhbbw+QWvmmvgxfnFJDfA=
github.com/beyondstorage/go-storage/v4 v4.0.0/go.mod h1:oa2dYco+xplPj99WSBnYVw/xXvRkIKWSSVDQKNZ5Kz8=
github.com/beyondstorage/go-storage/v4 v4.0.1-0.20210530044854-1c928ddbe52d h1:s9t6VNNRDqmg+PXyXtVEsxIM7xZQIJOYlma28IpkbNQ=
github.com/beyondstorage/go-storage/v4 v4.0.1-0.20210530044854-1c928ddbe52d/go.mod h1:kXMu07IDZaKtxbqI1ufuhqo0FjYe0nH7zPCbBanln/Y=
github.com/beyondstorage/specs/go v0.0.0-20210521044836-3d41c1d9c97f/go.mod h1:f5VvmLHc/dNJwl+/yAv/TOHdev3phvuEswx8DIXiSQQ=
github.com/beyondstorage/specs/go v0.0.0-20210530044123-3ff75e192bc9 h1:YSiF27cAHlDZk9q+oaEHQbA8dH8XTvYxeTOoPzNCwOQ=
github.com/beyondstorage/specs/go v0.0.0-20210530044123-3ff75e192bc9/go.mod h1:f5VvmLHc/dNJwl+/yAv/TOHdev3phvuEswx8DIXiSQQ=
github.com/beyondstorage/go-integration-test/v4 v4.1.0 h1:/cKM5uC+tW1mYAM/FTQlMq3EZMAb8hBm8gL4ZHk9InQ=
github.com/beyondstorage/go-integration-test/v4 v4.1.0/go.mod h1:W6Dhve1tbEpWAR1WSRuJl4UYpMNpM2QTAcb1dCpuEUI=
github.com/beyondstorage/go-storage/v4 v4.1.0 h1:O5SuSoTvs0KeXaZ/dYhpURlki6PjTNPyIzsJMY9sJWw=
github.com/beyondstorage/go-storage/v4 v4.1.0/go.mod h1:dK5DFnvKQI70bfpM1MLU9QqDYB12Z/dFV5sUnbJ/AoU=
github.com/beyondstorage/specs/go v0.0.0-20210608070420-9185b588aa58 h1:AvxsyR0bSSBi90WtYEMdAkM4Sm+Xxr7JVGXAQVVfeOo=
github.com/beyondstorage/specs/go v0.0.0-20210608070420-9185b588aa58/go.mod h1:1Az5o44awI/Ljop+ppO2djyezVfdKKb1RjJ6+M+a5XQ=
github.com/dave/dst v0.26.2 h1:lnxLAKI3tx7MgLNVDirFCsDTlTG9nKTk7GcptKcWSwY=
github.com/dave/dst v0.26.2/go.mod h1:UMDJuIRPfyUCC78eFuB+SV/WI8oDeyFDvM/JR6NI3IU=
github.com/dave/gopackages v0.0.0-20170318123100-46e7023ec56e/go.mod h1:i00+b/gKdIDIxuLDFob7ustLAVqhsZRk2qVZrArELGQ=
Expand All @@ -33,8 +31,8 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/pelletier/go-toml v1.9.1 h1:a6qW1EVNZWH9WGI6CsYdD8WAylkoXBS5yv0XHlh17Tc=
github.com/pelletier/go-toml v1.9.1/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
github.com/pelletier/go-toml v1.9.2 h1:7NiByeVF4jKSG1lDF3X8LTIkq2/bu+1uYbIm1eS5tzk=
github.com/pelletier/go-toml v1.9.2/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/qingstor/go-mime v0.1.0 h1:FhTJtM7TRm9pfgCXpjGUxqwbumGojrgE9ecRz5PXvfc=
Expand Down
8 changes: 7 additions & 1 deletion service.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,20 @@ implement = ["copier", "mover", "fetcher", "appender", "direr"]
optional = ["storage_features", "default_storage_pairs", "work_dir"]

[namespace.storage.op.create]
optional = ["multipart_id"]
optional = ["object_mode"]

[namespace.storage.op.delete]
optional = ["object_mode"]

[namespace.storage.op.list]
optional = ["continuation_token", "list_mode"]

[namespace.storage.op.read]
optional = ["offset", "io_callback", "size"]

[namespace.storage.op.stat]
optional = ["object_mode"]

[namespace.storage.op.write]
optional = ["content_md5", "content_type", "offset", "io_callback"]

Expand Down
10 changes: 8 additions & 2 deletions storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,16 @@ func (s *Storage) copy(ctx context.Context, src string, dst string, opt pairStor
}

func (s *Storage) create(path string, opt pairStorageCreate) (o *Object) {
o = s.newObject(false)
if opt.HasObjectMode && opt.ObjectMode.IsDir() {
o = s.newObject(false)
o.Mode = ModeDir
} else {
o = s.newObject(false)
o.Mode = ModeRead
}

o.ID = filepath.Join(s.workDir, path)
o.Path = path
o.Mode = ModeRead
return o
}

Expand Down
7 changes: 7 additions & 0 deletions tests/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,10 @@ func TestAppend(t *testing.T) {
}
tests.TestAppender(t, setupTest(t))
}

func TestDir(t *testing.T) {
if os.Getenv("STORAGE_FS_INTEGRATION_TEST") != "on" {
t.Skipf("STORAGE_FS_INTEGRATION_TEST is not 'on', skipped")
}
tests.TestDirer(t, setupTest(t))
}

0 comments on commit fa77bdb

Please sign in to comment.