We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
오부경
9 years agoExplorer | Level 4
longpoll api returns always true when I added shared folder to my drive
When I added shared folder to my drive, longpoll api immediately returns true (no wait). list_folder api for root folder returns new cursor and longpoll api by root cursor returns true. When it ret...
Greg-DB
Dropbox Community Moderator
9 years agoThanks! That's helpful. We're looking into it.
오부경
9 years agoExplorer | Level 4
I'm sorry for the short English. I used Google Translator
I have read dropbox documents very deeply again on this issue.
If I use get_lastest_cursor and longpoll to get changes only, I'm using it wrong.
I realized I could get a Delta using the "list_folder/continue" call.
So, I came to understand the relationship between Cursor and Delta in turn.
I've found that it works well only with a good understanding of the behavior of get_lastest_cursor, longpoll, and list_folder/continue.
After modifying the code, it works fine now.
For someone like me, leave the reference code below.
Thanks Greg K.
void CheckChanges()
{
string LastCursor = String.Empty;
// first step : get new cursor and keep
Task task = Task.Run(async () =>
{
ListFolderArg arg = new ListFolderArg("", true, false, true, false);
var result = await Client.Files.ListFolderGetLatestCursorAsync(arg);
LastCursor = result.Cursor;
});
task.Wait();
// loop : detect changes and get delta
while(!EndOfCheck)
{
bool doGetDelta = false;
Task task = Task.Run(async () =>
{
try
{
var longpoll = await Client.Files.ListFolderLongpollAsync(PathFile.Cursor);
doGetDelta = longpoll.Changes;
}
catch
{
}
});
task.Wait();
if(doGetDelta)
{
List<MyChangeInfo> changeList = new List<MyChangeInfo>();
ListFolderContinueArg arg = new ListFolderContinueArg(LastChangeCursor);
Task task = Task.Run(async () =>
{
try
{
var continueResult = await Client.Files.ListFolderContinueAsync(arg);
LastChangeCursor = continueResult.Cursor; // keep cursor
if (continueResult.Entries != null && continueResult.Entries.Count > 0)
{
foreach (var entry in continueResult.Entries)
{
MyChangeInfo change = new MyChangeInfo();
change.key = entry.PathLower;
change.metadata = entry;
change.removed = entry.IsDeleted;
changeList.Add(change);
}
}
}
catch
{
}
});
task.Wait();
if(newList.Count > 0)
{
// Do Apply Changes
foreach(var change in newList)
{
if(change.removed)
{
// do delete file or folder
}
else
{
// do update or add
}
}
}
}
}
}
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
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, Facebook or Instagram.
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!