You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

Qrab's avatar
Qrab
Explorer | Level 3
10 months ago

Changing many file access rights with api

Hello,

I'm looking to move a large amount of folders from directory A to directory B. For this I use fileCopyV2 with a little delay between each move to avoid too_many_request and everything works fine. However, I also need to change the access rights to these folders during the transfer. I need to make sure that the inherit rights from the new parent folder disappear, and that the new rights are applied. To do this, I use multithreading so that I don't block my script. To remove the rights I start by sharing the folder, then I wait a few seconds for the folder to be shared. I retrieve his sharing_id and use it to remove all access to the folder. Then I add the new rights.

My problem is that I always get the too_many_write_opérations error. With a message asking me to wait 30 seconds. I could add delays, but I have to transfer thousands of folders, so if I add enough time I'll have to run my script for days. Outside of that, it's impossible. So I wanted to know if there is an easier way to make my project a reality. Or if optimization is possible.

 

Thanks in advance

 

Qrab

  • iNeil's avatar
    iNeil
    Icon for Dropbox Engineer rankDropbox Engineer

    Qrab, If there are multiple changes at the same time in the same account or shared folder, you can run in to this 'too_many_write_operations' error, which is "lock contention". That's not explicit rate limiting, but rather a result of how Dropbox works on the back-end. This is a technical inability to make a modification in the account or shared folder at the time of the API call. 

     

    This applies to all account types. This error indicates that there was simultaneous activity in the account or shared/team folder preventing your app from making the state-modifying call (e.g., adding, editing, moving, copying, sharing, or deleting files/folders) it is attempting. The simultaneous activity could be coming from your app itself, or elsewhere, e.g., from the user's desktop client. It can come from the same user, or another member of a shared folder. You can find more information about lock contention and optimizations you can make here. The app will need to be written to automatically handle this error.

    In short, to avoid this error, you should avoid making multiple concurrent state modifications and use batch endpoints where possible. That won't guarantee that you won't run in to this error though, as contention can still come from other sources, so you should also implement error handling and automatic retrying as needed. I recommend referring to the error documentation and Error Handling Guide for more information.

     

    Based on the information you have provided, you are using the filesCopyV2 method to copy individual files and folders. An alternative approach would be using the filesCopyBatchV2 method instead. This will allow you to copy multiple files or folders to different locations at once in the user's Dropbox. While using the filesCopyBatchV2 method, you can cross-check if it's completed by using the filesCopyBatchCheckV2 method. 

     

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,888 PostsLatest Activity: 21 hours ago
326 Following

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!