drime: fix files and directories being created in the default workspace
Before this change directories and files were created in the default workspace, not the workspace specified by --drime-workspace-id.
This commit is contained in:
@@ -173,6 +173,7 @@ type MultiPartCreateRequest struct {
|
|||||||
Extension string `json:"extension"`
|
Extension string `json:"extension"`
|
||||||
ParentID json.Number `json:"parent_id"`
|
ParentID json.Number `json:"parent_id"`
|
||||||
RelativePath string `json:"relativePath"`
|
RelativePath string `json:"relativePath"`
|
||||||
|
WorkspaceID string `json:"workspaceId,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// MultiPartCreateResponse is returned by POST /s3/multipart/create
|
// MultiPartCreateResponse is returned by POST /s3/multipart/create
|
||||||
|
|||||||
+26
-8
@@ -476,8 +476,12 @@ func (f *Fs) createDir(ctx context.Context, pathID, leaf string, modTime time.Ti
|
|||||||
var resp *http.Response
|
var resp *http.Response
|
||||||
var result api.CreateFolderResponse
|
var result api.CreateFolderResponse
|
||||||
opts := rest.Opts{
|
opts := rest.Opts{
|
||||||
Method: "POST",
|
Method: "POST",
|
||||||
Path: "/folders",
|
Path: "/folders",
|
||||||
|
Parameters: url.Values{},
|
||||||
|
}
|
||||||
|
if f.opt.WorkspaceID != "" {
|
||||||
|
opts.Parameters.Set("workspaceId", f.opt.WorkspaceID)
|
||||||
}
|
}
|
||||||
mkdir := api.CreateFolderRequest{
|
mkdir := api.CreateFolderRequest{
|
||||||
Name: f.opt.Enc.FromStandardName(leaf),
|
Name: f.opt.Enc.FromStandardName(leaf),
|
||||||
@@ -779,8 +783,12 @@ func (f *Fs) patch(ctx context.Context, id, attribute string, value string) (ite
|
|||||||
}
|
}
|
||||||
var result api.UpdateItemResponse
|
var result api.UpdateItemResponse
|
||||||
opts := rest.Opts{
|
opts := rest.Opts{
|
||||||
Method: "PUT",
|
Method: "PUT",
|
||||||
Path: "/file-entries/" + id,
|
Path: "/file-entries/" + id,
|
||||||
|
Parameters: url.Values{},
|
||||||
|
}
|
||||||
|
if f.opt.WorkspaceID != "" {
|
||||||
|
opts.Parameters.Set("workspaceId", f.opt.WorkspaceID)
|
||||||
}
|
}
|
||||||
err = f.pacer.Call(func() (bool, error) {
|
err = f.pacer.Call(func() (bool, error) {
|
||||||
resp, err = f.srv.CallJSON(ctx, &opts, &request, &result)
|
resp, err = f.srv.CallJSON(ctx, &opts, &request, &result)
|
||||||
@@ -807,8 +815,12 @@ func (f *Fs) move(ctx context.Context, id, newDirID string) (err error) {
|
|||||||
}
|
}
|
||||||
var result api.MoveResponse
|
var result api.MoveResponse
|
||||||
opts := rest.Opts{
|
opts := rest.Opts{
|
||||||
Method: "POST",
|
Method: "POST",
|
||||||
Path: "/file-entries/move",
|
Path: "/file-entries/move",
|
||||||
|
Parameters: url.Values{},
|
||||||
|
}
|
||||||
|
if f.opt.WorkspaceID != "" {
|
||||||
|
opts.Parameters.Set("workspaceId", f.opt.WorkspaceID)
|
||||||
}
|
}
|
||||||
err = f.pacer.Call(func() (bool, error) {
|
err = f.pacer.Call(func() (bool, error) {
|
||||||
resp, err = f.srv.CallJSON(ctx, &opts, &request, &result)
|
resp, err = f.srv.CallJSON(ctx, &opts, &request, &result)
|
||||||
@@ -945,8 +957,12 @@ func (f *Fs) copy(ctx context.Context, id, newDirID string) (item *api.Item, err
|
|||||||
}
|
}
|
||||||
var result api.CopyResponse
|
var result api.CopyResponse
|
||||||
opts := rest.Opts{
|
opts := rest.Opts{
|
||||||
Method: "POST",
|
Method: "POST",
|
||||||
Path: "/file-entries/duplicate",
|
Path: "/file-entries/duplicate",
|
||||||
|
Parameters: url.Values{},
|
||||||
|
}
|
||||||
|
if f.opt.WorkspaceID != "" {
|
||||||
|
opts.Parameters.Set("workspaceId", f.opt.WorkspaceID)
|
||||||
}
|
}
|
||||||
err = f.pacer.Call(func() (bool, error) {
|
err = f.pacer.Call(func() (bool, error) {
|
||||||
resp, err = f.srv.CallJSON(ctx, &opts, &request, &result)
|
resp, err = f.srv.CallJSON(ctx, &opts, &request, &result)
|
||||||
@@ -1114,6 +1130,7 @@ func (f *Fs) OpenChunkWriter(ctx context.Context, remote string, src fs.ObjectIn
|
|||||||
Extension: strings.TrimPrefix(path.Ext(leaf), `.`),
|
Extension: strings.TrimPrefix(path.Ext(leaf), `.`),
|
||||||
ParentID: json.Number(directoryID),
|
ParentID: json.Number(directoryID),
|
||||||
RelativePath: f.opt.Enc.FromStandardPath(path.Join(f.root, remote)),
|
RelativePath: f.opt.Enc.FromStandardPath(path.Join(f.root, remote)),
|
||||||
|
WorkspaceID: f.opt.WorkspaceID,
|
||||||
}
|
}
|
||||||
|
|
||||||
var resp api.MultiPartCreateResponse
|
var resp api.MultiPartCreateResponse
|
||||||
@@ -1540,6 +1557,7 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op
|
|||||||
MultipartParams: url.Values{
|
MultipartParams: url.Values{
|
||||||
"parentId": {directoryID},
|
"parentId": {directoryID},
|
||||||
"relativePath": {encodedLeaf},
|
"relativePath": {encodedLeaf},
|
||||||
|
"workspaceId": {o.fs.opt.WorkspaceID},
|
||||||
},
|
},
|
||||||
MultipartContentName: "file",
|
MultipartContentName: "file",
|
||||||
MultipartFileName: encodedLeaf,
|
MultipartFileName: encodedLeaf,
|
||||||
|
|||||||
Reference in New Issue
Block a user