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

ensureDirectory function would be handy #118

Closed
tansaku opened this issue Nov 27, 2018 · 2 comments · Fixed by #253
Closed

ensureDirectory function would be handy #118

tansaku opened this issue Nov 27, 2018 · 2 comments · Fixed by #253

Comments

@tansaku
Copy link
Contributor

tansaku commented Nov 27, 2018

an ensureDirectory function that took a path and ensured that it existed would be pretty handy ... e.g.

client.ensureDirectory('/tmp/foo/bar') // ensures that each directory in the path exists
@perry-mitchell
Copy link
Owner

This will be available via #253 by calling the following:

client.createDirectory("/tmp/foo/bar", { recursive: true });

@eric-burel
Copy link

eric-burel commented Mar 23, 2022

Hi, I suspect current implementation doesn't resist to race conditions. Between the moment you run "stats" and the moment your run "createDirectory", the directory might actually have been created. You should probably add an additional "try/catch" that ignores "405" errors when the creation fails for a subpath, it means that another call already created this subpath.

Here precisely: https://github.com/perry-mitchell/webdav-client/blob/master/source/operations/createDirectory.ts#L64-L72
The race happens between these lines. I observe that when moving files in batch to a copied folder.

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

Successfully merging a pull request may close this issue.

3 participants