Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
Hey Greg,
I've tried to adapt this code in order to get a bunch of files that begin with the letters 'zas', but I found the script just ran for hours without any luck, so I stripped it back to see what was happening.
I define my root and result:
root_path = '/MarketingCreative/External/Bidalgo_Zynga_CSR2/' result = dbx.files_list_folder(root_path, recursive=True)
And then I'm just printing the file name if its a file, and the folder name if it's a folder:
def process_entries(entries): for entry in entries: if isinstance(entry, dropbox.files.FileMetadata): file = entry.path_display.rsplit('/', 1)[1] print(file) else: print("Folder "+entry.path_display) process_entries(result.entries) while result.has_more: result = dbx.files_list_folder_continue(result.cursor) process_entries(result.entries)
Again, this is just to see why the script is taking so long with no results.
It seems that after the first few files, the script just keeps repeating the root folder, and not progressing the the subfolders (and files) within (see photos).
If I specific a sub folder in the root path, eg:
root_path = '/MarketingCreative/External/Bidalgo_Zynga_CSR2/C2_112118_2.1_FormulaItalia3_Trailer_VS_AlfaRomeo_[LOC]/' result = dbx.files_list_folder(root_path, recursive=True)
The script does what I need it to, but at this one level up, it seems to be an infinite loop.
How could I go about debugging this? Is it a cursor issue do you think?
Thanks
Nothing looks clearly wrong in the code. Can you add some extra logging to see:
Alternatively, you can step through with a debugger to inspect this interactively.
The cursor is definitely changing:
/MarketingCreative/External/Bidalgo_Zynga_CSR2 AAE0hozJExL3S0MSePeqiKCWxFrYSYHlKaVrjL587setM0OKa4pyMp363SxU-HkSHEqgiOcrqKrvzc_LNfxuLMCzqnJBhdZlFdiywbVrO1LtvaZQ8_K-YDSCvZhEGXE4WLubSEivzHFm8BzLTzLJGWbIi2Qd8EBibzeVpJB_1DtqqOPJ0Wz-SUaMHnGsisFikWW5Gbtl6FBjHHFcuhPClt9adQobe0JxtU5doi8Mw-gu-QmiUd_UyNl-_XlItsPjWg11psAhW-F1_HmkWl8-CEOb3EkXzwEwtf-TNiScpgtzrLf2NGxmDyQ6smjrIwqxVbJsEmzsfuTonlOdlz7_PtGusXpcrDlqzXSi4XWqS4x47haSKyC9te0OkhpZu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d91eyJZUcIpTc4YP1-wxHRrxewVds_Fyk0NUzeXEAMIApUweRbybG-IDCugHirdEJLuQdLX0fBHihXPDOOSnekCR6pWDmzKiP0lFjHMA6bPUy1A-jaw2zg_ven5_oAXixbdpE7ka5y308LPSD4UM-w6a5eSsHcVHFz1fQlNDtcBG3r1zO2v3hsi-lpS7MhpWe7ti8dT1seujZPrw9axDO50wvEPFHvkvi7nFa09M7qXUal3GWNOcwP1dfKiLey1fo__JVFQTMqyGKriR84pR6wyXkAGQqjhr_qkRnZ3Rf60fvuKH2fwXP5KpP_-7jWy7BSt92QDnZpIcK_PaEJBEvjN798-rNwf_J9wgeMzN2jcavhURKapPE5y9pA4R4TzeCLdnXnaQ6I24gYGX9KSYnLKnDrNnxP9tvsZo04Zir5cqWYEe7TmCg4uB-sXQjy-qWbBCwJKTui0zSDg_tLaJ3jCFDAjQ
How would I go about finding how many calls are being made to files_list_folder and files_list_folder_continue (other than what already exists)?
It seems like the script just resorts to /MarketingCreative/External/Bidalgo_Zynga_CSR2 and stays there.
I've let it run for 10k+ iterations a couple of times and the same situation.
Thanks 🙂
Thanks! Can you share the updated code with this extra logging too? That would help illustrate what exactly is producing this output.
As for the number of calls being made, you don't need an actual counter; I just meant to illustrate each call to files_list_folder and files_list_folder_continue, which your logging appears to be doing now. That is, there are apparently an unbounded number of calls, with each one returning a list with just one entry. That can happen, but it shouldn't repeat, as long as you pass the returned cursor back into files_list_folder_continue. You appear to be doing so, so we'll need to debug that further. Seeing where your logging occurs may help.
Sure thing, code is here:
root_path = '/MarketingCreative/External/Bidalgo_Zynga_CSR2/' result = dbx.files_list_folder(root_path, recursive=True) def process_entries(entries): for entry in entries: print(entry.path_display) print(result.cursor) if isinstance(entry, dropbox.files.FileMetadata): file = entry.path_display.rsplit('/', 1)[1] if file.startswith('zas'): print(file) process_entries(result.entries) while result.has_more: result = dbx.files_list_folder_continue(result.cursor) process_entries(result.entries)
Thing is, I'm trying to get all the files that start with 'zas', and I can do this, if I specify the root folder one level below what I currently have, but that's no good to me as I need all the files within the current root folder.
But again, it just seems to be looping infinitely. 😕
Thanks again for your help 🙂
Thanks, that's helpful. That confirms you're getting one identical entry per page, and a different cursor for each page.
This doesn't reproduce for me, so we'll need to investigate further on the server-side to find out why this is happening for you. I'll follow up here once I have an update for you.
Hey Greg 🙂 Any luck on this?
This is currently open with engineering, but I don't have an update on it yet. I'll follow up here once I do.
Engineering let me know they're looking into it, but unfortunately we don't have a timeline for a fix right now.
That being the case, you may want to use files_search_v2/files_search_continue_v2 as a workaround for now.
Hi where are you with this issue, as we backup our files to dropbox business, and we can no longer do an integrity check to verify our backup from synology. If you cannot resolve this issue, we will have to go else where as we cannot verify that our files are being backed up, and we cannot afford to loose any data if we have to restore from backup.
The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.
Sound good? Let's get started.Hi there!
If you need more help you can view your support options (expected response time for a ticket is 24 hours), or contact us on Twitter or Facebook.
For more info on available support options, see this article.
If you found the answer to your question, please 'like' the post to say thanks to the user!