Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement GSP-49 Add CreateDir Operation #560

Closed
14 tasks done
Xuanwo opened this issue May 8, 2021 · 4 comments
Closed
14 tasks done

Implement GSP-49 Add CreateDir Operation #560

Xuanwo opened this issue May 8, 2021 · 4 comments
Milestone

Comments

@JinnyYi
Copy link
Contributor

JinnyYi commented Jun 3, 2021

I have some questions:

  • Is it necessary to check the path parameter?
    For object storage, may be we need to add / at the end of path. But paths may not end with a slash or whitespace in dropbox.
  • Is it allowed to create root directory?
  • How to deal with file and directory with the same name?
    • For file system, a file and a subdirectory in the same directory with the same name are not allowed.
    • For object storage, test and test/ exist simultaneously is allowed. Should we check whether the file or directory exist if we implement CreateDir through store.Write("abc/", nil, 0, ps.WithContentType("application/x-directory")) in object storage?
  • How to deal with creating an existing dir?
    • For file system, create an existing dir will get File exists error.
    • For dropbox, calling CreateFolderV2 to create an existing dir will get path/conflict/folder/. error.
    • For object storage, calling PutObject to create an existing object will overwrite it.
  • Impact on other interfaces:
    • CreateAppend/Create(with MultipartId)/write: the path parameter shoud not be abc/ liked (abc/xxx allowed).
    • Delete: Only allowed to delete a file or an empty directory (If allowed to delete recursively, os.RemoveAll() should be called in fs, List need to call first for object storage, config.Folder should be set true for uss)?
    • ...
  • How to implement CreateDir in kodo?
    An alternative way is to Put an empty file first, then modify the mimetype to application/x-directory through ChangeMime. But we will get the MD5 of the simulated folder from ListFiles which is puzzling.

@Xuanwo
Copy link
Contributor Author

Xuanwo commented Jun 3, 2021

Nice question list, I think we should add them in both GSP and CreateDir comments.


Is it necessary to check the path parameter?

We can add a limit for CreateDir: path should not be ended with /.

Object storage should add / at the end of path to simulate a directory.

Is it allowed to create root directory?

No, and it's not needed: WorkDir should be created by services while init.

How to deal with file and directory with the same name?

It's storage service behavior, let's just follow them. I think it's OK. Just make it clear in CreateDir's comment.

  • For fs, we return an error.
  • For object storage, we allow test and test/ to exist at the same time.

How to deal with creating an existing dir?

It's storage service behavior, let's just follow them. I think it's OK. Just make it clear in CreateDir's comment.

  • For fs, we return an error.
  • For object storage, just overwrite them.

Notice: CreateDir for object storage service should be a virtual function, users should enable them and we should add comments for all these limitations.

CreateAppend/Create(with MultipartId)/write

For all API, we don't allow user input path ends with /.

In Create, we create a dir object like: Create("test", ps.WithObjectMode(ObjectModeDir))

Delete

We only support deleting a single object which means a normal object or an empty dir object.

And we should never call API like os.RemoveAll() in our services.

How to implement CreateDir in kodo?

Let's discuss this in kodo's PR.

@Xuanwo Xuanwo changed the title Implement AOS-49 Add CreateDir Operation Implement GSP-49 Add CreateDir Operation Jun 8, 2021
@Xuanwo
Copy link
Contributor Author

Xuanwo commented Jun 8, 2021

Now we have GSP-93, the behavior should be changed.

@JinnyYi
Copy link
Contributor

JinnyYi commented Jun 15, 2021

Pause for beyondstorage/specs#107.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants