<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: API v2 - Long polling in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/API-v2-Long-polling/m-p/247955#M14218</link>
    <description>&lt;P&gt;Hi Frank, I'll be happy to help here.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"&lt;STRONG&gt;Question 1&lt;/STRONG&gt;: Is this really the most efficient way that this can be done?"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Reading through your description (thank you for the detailed write up, it really helps), I believe there are a few optimizations to make:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;a) "does a files.listFolder" ... "files.listFolderContinue" ... "then for each file it does a files.getMetaData and compares the rev":&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you've already done &lt;A href="https://dropbox.github.io/SwiftyDropbox/api-docs/latest/Classes/FilesRoutes.html#/s:13SwiftyDropbox11FilesRoutesC10listFolderAA10RpcRequestCyAA0C0C04ListF16ResultSerializerCAH0if5ErrorK0CGSS4path_Sb9recursiveSb16includeMediaInfoSb0O7DeletedSb0O24HasExplicitSharedMembersSb0O14MountedFolderss6UInt32VSg5limittF" target="_self"&gt;files.listFolder&lt;/A&gt;/&lt;A href="https://dropbox.github.io/SwiftyDropbox/api-docs/latest/Classes/FilesRoutes.html#/s:13SwiftyDropbox11FilesRoutesC18listFolderContinueAA10RpcRequestCyAA0C0C04ListF16ResultSerializerCAH0jfg5ErrorL0CGSS6cursor_tF" target="_self"&gt;files.listFolderContinue&lt;/A&gt;, you don't also need to call &lt;A href="https://dropbox.github.io/SwiftyDropbox/api-docs/latest/Classes/FilesRoutes.html#/s:13SwiftyDropbox11FilesRoutesC11getMetadataAA10RpcRequestCyAA0C0C0F10SerializerCAH03Getf5ErrorI0CGSS4path_Sb16includeMediaInfoSb0M7DeletedSb0M24HasExplicitSharedMemberstF" target="_self"&gt;files.getMetadata&lt;/A&gt;&amp;nbsp;for each file. That just returns the same &lt;A href="https://dropbox.github.io/SwiftyDropbox/api-docs/latest/Classes/Files/Metadata.html" target="_self"&gt;Metadata&lt;/A&gt; objects as&amp;nbsp;were already returned in&amp;nbsp;&lt;A href="https://dropbox.github.io/SwiftyDropbox/api-docs/latest/Classes/Files/ListFolderResult.html#/s:13SwiftyDropbox5FilesC16ListFolderResultC7entriesSayAC8MetadataCGv" target="_self"&gt;ListFolderResult.entries&lt;/A&gt;&amp;nbsp;from&amp;nbsp;&lt;A href="https://dropbox.github.io/SwiftyDropbox/api-docs/latest/Classes/FilesRoutes.html#/s:13SwiftyDropbox11FilesRoutesC10listFolderAA10RpcRequestCyAA0C0C04ListF16ResultSerializerCAH0if5ErrorK0CGSS4path_Sb9recursiveSb16includeMediaInfoSb0O7DeletedSb0O24HasExplicitSharedMembersSb0O14MountedFolderss6UInt32VSg5limittF" target="_self"&gt;files.listFolder&lt;/A&gt;&lt;SPAN&gt;/&lt;/SPAN&gt;&lt;A href="https://dropbox.github.io/SwiftyDropbox/api-docs/latest/Classes/FilesRoutes.html#/s:13SwiftyDropbox11FilesRoutesC18listFolderContinueAA10RpcRequestCyAA0C0C04ListF16ResultSerializerCAH0jfg5ErrorL0CGSS6cursor_tF" target="_self"&gt;files.listFolderContinue&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Part of the confusion may be that you need to cast the&amp;nbsp;&lt;A href="https://dropbox.github.io/SwiftyDropbox/api-docs/latest/Classes/Files/Metadata.html" target="_self"&gt;Metadata&lt;/A&gt;&amp;nbsp;to e.g., &lt;A href="https://dropbox.github.io/SwiftyDropbox/api-docs/latest/Classes/Files/FileMetadata.html" target="_self"&gt;FileMetadata&lt;/A&gt; to access &lt;A href="https://dropbox.github.io/SwiftyDropbox/api-docs/latest/Classes/Files/FileMetadata.html#/s:13SwiftyDropbox5FilesC12FileMetadataC3revSSv" target="_self"&gt;FileMetadata.rev&lt;/A&gt;&amp;nbsp;though, as shown &lt;A href="https://github.com/dropbox/SwiftyDropbox#response-handling-edge-cases" target="_self"&gt;here&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;b) "if an updates occurs it restarts the entire sync process":&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You don't need to start totally over. When &lt;A href="https://dropbox.github.io/SwiftyDropbox/api-docs/latest/Classes/FilesRoutes.html#/s:13SwiftyDropbox11FilesRoutesC18listFolderLongpollAA10RpcRequestCyAA0C0C04ListfG16ResultSerializerCAH0jfg5ErrorL0CGSS6cursor_s6UInt64V7timeouttF" target="_self"&gt;files.listFolderLongPoll&lt;/A&gt;&amp;nbsp;indicates something changed, you should just call back to&amp;nbsp;&lt;A href="https://dropbox.github.io/SwiftyDropbox/api-docs/latest/Classes/FilesRoutes.html#/s:13SwiftyDropbox11FilesRoutesC18listFolderContinueAA10RpcRequestCyAA0C0C04ListF16ResultSerializerCAH0jfg5ErrorL0CGSS6cursor_tF" target="_self"&gt;files.listFolderContinue&lt;/A&gt;&amp;nbsp;with the&amp;nbsp;latest cursor you recieved, and it will tell you only about what has changed since then. (You should just continue applying the same steps from the&amp;nbsp;&lt;A href="https://dropbox.github.io/SwiftyDropbox/api-docs/latest/Classes/FilesRoutes.html#/s:13SwiftyDropbox11FilesRoutesC10listFolderAA10RpcRequestCyAA0C0C04ListF16ResultSerializerCAH0if5ErrorK0CGSS4path_Sb9recursiveSb16includeMediaInfoSb0O7DeletedSb0O24HasExplicitSharedMembersSb0O14MountedFolderss6UInt32VSg5limittF" target="_self"&gt;files.listFolder&lt;/A&gt;&amp;nbsp;documentation to apply those additional changes to your local state to get up to date.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"&lt;STRONG&gt;Question 2&lt;/STRONG&gt;: Is there are way of polling only for changes to a specific directory?"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;No, unfortunately&amp;nbsp;&lt;A href="https://dropbox.github.io/SwiftyDropbox/api-docs/latest/Classes/FilesRoutes.html#/s:13SwiftyDropbox11FilesRoutesC18listFolderLongpollAA10RpcRequestCyAA0C0C04ListfG16ResultSerializerCAH0jfg5ErrorL0CGSS6cursor_s6UInt64V7timeouttF" target="_self"&gt;files.listFolderLongPoll&lt;/A&gt;&amp;nbsp;will notify of changes in the account even if the changes only&amp;nbsp;occurred outside of the path originally specified in the path set in the original&amp;nbsp;&lt;A href="https://dropbox.github.io/SwiftyDropbox/api-docs/latest/Classes/FilesRoutes.html#/s:13SwiftyDropbox11FilesRoutesC10listFolderAA10RpcRequestCyAA0C0C04ListF16ResultSerializerCAH0if5ErrorK0CGSS4path_Sb9recursiveSb16includeMediaInfoSb0O7DeletedSb0O24HasExplicitSharedMembersSb0O14MountedFolderss6UInt32VSg5limittF" target="_self"&gt;files.listFolder&lt;/A&gt;&amp;nbsp;call. We'll consider that a feature request, but I don't know if/when that would be implemented. (It would be non-trivial due to the way these pieces of infrastructure work on the backend.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps, and thanks for the kind words about the support!&lt;/P&gt;</description>
    <pubDate>Thu, 19 Oct 2017 16:34:54 GMT</pubDate>
    <dc:creator>Greg-DB</dc:creator>
    <dc:date>2017-10-19T16:34:54Z</dc:date>
    <item>
      <title>API v2 - Long polling</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/API-v2-Long-polling/m-p/247873#M14207</link>
      <description>&lt;P&gt;I'm in the process of migrating from the V1 Sync API to the V2 "DIY" API and I would really appreciate some feedback on whether I'm really approaching this correctly, especially with regards to reacting to remote changes and the seemingly insanely heavy network traffic requried by my "solution".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using Dropbox to keep my iOS and Mac apps synched, so that both show the same "event logs". On the Mac those logs are stored in "My Folder" folder.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On startup, the iOS version (Swift)&amp;nbsp;does&amp;nbsp;a files.listFolder for "My Folder" and subsequent files.listFolderContinue until it has a complete file list, then for each file it does a files.getMetaData and compares the rev (revision) field in the meta with the rev value stored in my local DIY rev-to-file-path database. If the revs are different, it does a files.download for the file and writes to local storage.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After all local files are up-to-date, &amp;nbsp;it does a files.listFolderLongPoll and waits for any updates, if an updates occurs it restarts the entire sync process.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All this results, for &lt;STRONG&gt;n&lt;/STRONG&gt; log files, in at least &lt;STRONG&gt;n+1&lt;/STRONG&gt; network requests when there's nothing to by synched and &lt;STRONG&gt;2*n+1&lt;/STRONG&gt; network requests in the worst case. There's a log file for each day of use, so after a year, we have 366 to&amp;nbsp;731 network requests..&amp;nbsp;&lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@A6644A0BF80A0EB338701314992BEB55/images/emoticons/1f631.png" alt=":scream:" title=":scream:" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Question 1&lt;/STRONG&gt;: Is this really the most efficient way that this can be done?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Question 2&lt;/STRONG&gt;: Is there are way of polling only for changes to a specific directory?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BTW I really appreciate the great job the support team is doing; even as I'm perplexed by the new API &lt;img class="lia-deferred-image lia-image-emoji" src="https://www.dropboxforum.com/html/@FBF7D2AB59A0D6E861EBF6A36F93B7E2/emoticons/1f642.png" alt=":slightly_smiling_face:" title=":slightly_smiling_face:" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 09:18:04 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/API-v2-Long-polling/m-p/247873#M14207</guid>
      <dc:creator>Frank R.15</dc:creator>
      <dc:date>2019-05-29T09:18:04Z</dc:date>
    </item>
    <item>
      <title>Re: API v2 - Long polling</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/API-v2-Long-polling/m-p/247955#M14218</link>
      <description>&lt;P&gt;Hi Frank, I'll be happy to help here.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"&lt;STRONG&gt;Question 1&lt;/STRONG&gt;: Is this really the most efficient way that this can be done?"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Reading through your description (thank you for the detailed write up, it really helps), I believe there are a few optimizations to make:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;a) "does a files.listFolder" ... "files.listFolderContinue" ... "then for each file it does a files.getMetaData and compares the rev":&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you've already done &lt;A href="https://dropbox.github.io/SwiftyDropbox/api-docs/latest/Classes/FilesRoutes.html#/s:13SwiftyDropbox11FilesRoutesC10listFolderAA10RpcRequestCyAA0C0C04ListF16ResultSerializerCAH0if5ErrorK0CGSS4path_Sb9recursiveSb16includeMediaInfoSb0O7DeletedSb0O24HasExplicitSharedMembersSb0O14MountedFolderss6UInt32VSg5limittF" target="_self"&gt;files.listFolder&lt;/A&gt;/&lt;A href="https://dropbox.github.io/SwiftyDropbox/api-docs/latest/Classes/FilesRoutes.html#/s:13SwiftyDropbox11FilesRoutesC18listFolderContinueAA10RpcRequestCyAA0C0C04ListF16ResultSerializerCAH0jfg5ErrorL0CGSS6cursor_tF" target="_self"&gt;files.listFolderContinue&lt;/A&gt;, you don't also need to call &lt;A href="https://dropbox.github.io/SwiftyDropbox/api-docs/latest/Classes/FilesRoutes.html#/s:13SwiftyDropbox11FilesRoutesC11getMetadataAA10RpcRequestCyAA0C0C0F10SerializerCAH03Getf5ErrorI0CGSS4path_Sb16includeMediaInfoSb0M7DeletedSb0M24HasExplicitSharedMemberstF" target="_self"&gt;files.getMetadata&lt;/A&gt;&amp;nbsp;for each file. That just returns the same &lt;A href="https://dropbox.github.io/SwiftyDropbox/api-docs/latest/Classes/Files/Metadata.html" target="_self"&gt;Metadata&lt;/A&gt; objects as&amp;nbsp;were already returned in&amp;nbsp;&lt;A href="https://dropbox.github.io/SwiftyDropbox/api-docs/latest/Classes/Files/ListFolderResult.html#/s:13SwiftyDropbox5FilesC16ListFolderResultC7entriesSayAC8MetadataCGv" target="_self"&gt;ListFolderResult.entries&lt;/A&gt;&amp;nbsp;from&amp;nbsp;&lt;A href="https://dropbox.github.io/SwiftyDropbox/api-docs/latest/Classes/FilesRoutes.html#/s:13SwiftyDropbox11FilesRoutesC10listFolderAA10RpcRequestCyAA0C0C04ListF16ResultSerializerCAH0if5ErrorK0CGSS4path_Sb9recursiveSb16includeMediaInfoSb0O7DeletedSb0O24HasExplicitSharedMembersSb0O14MountedFolderss6UInt32VSg5limittF" target="_self"&gt;files.listFolder&lt;/A&gt;&lt;SPAN&gt;/&lt;/SPAN&gt;&lt;A href="https://dropbox.github.io/SwiftyDropbox/api-docs/latest/Classes/FilesRoutes.html#/s:13SwiftyDropbox11FilesRoutesC18listFolderContinueAA10RpcRequestCyAA0C0C04ListF16ResultSerializerCAH0jfg5ErrorL0CGSS6cursor_tF" target="_self"&gt;files.listFolderContinue&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Part of the confusion may be that you need to cast the&amp;nbsp;&lt;A href="https://dropbox.github.io/SwiftyDropbox/api-docs/latest/Classes/Files/Metadata.html" target="_self"&gt;Metadata&lt;/A&gt;&amp;nbsp;to e.g., &lt;A href="https://dropbox.github.io/SwiftyDropbox/api-docs/latest/Classes/Files/FileMetadata.html" target="_self"&gt;FileMetadata&lt;/A&gt; to access &lt;A href="https://dropbox.github.io/SwiftyDropbox/api-docs/latest/Classes/Files/FileMetadata.html#/s:13SwiftyDropbox5FilesC12FileMetadataC3revSSv" target="_self"&gt;FileMetadata.rev&lt;/A&gt;&amp;nbsp;though, as shown &lt;A href="https://github.com/dropbox/SwiftyDropbox#response-handling-edge-cases" target="_self"&gt;here&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;b) "if an updates occurs it restarts the entire sync process":&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You don't need to start totally over. When &lt;A href="https://dropbox.github.io/SwiftyDropbox/api-docs/latest/Classes/FilesRoutes.html#/s:13SwiftyDropbox11FilesRoutesC18listFolderLongpollAA10RpcRequestCyAA0C0C04ListfG16ResultSerializerCAH0jfg5ErrorL0CGSS6cursor_s6UInt64V7timeouttF" target="_self"&gt;files.listFolderLongPoll&lt;/A&gt;&amp;nbsp;indicates something changed, you should just call back to&amp;nbsp;&lt;A href="https://dropbox.github.io/SwiftyDropbox/api-docs/latest/Classes/FilesRoutes.html#/s:13SwiftyDropbox11FilesRoutesC18listFolderContinueAA10RpcRequestCyAA0C0C04ListF16ResultSerializerCAH0jfg5ErrorL0CGSS6cursor_tF" target="_self"&gt;files.listFolderContinue&lt;/A&gt;&amp;nbsp;with the&amp;nbsp;latest cursor you recieved, and it will tell you only about what has changed since then. (You should just continue applying the same steps from the&amp;nbsp;&lt;A href="https://dropbox.github.io/SwiftyDropbox/api-docs/latest/Classes/FilesRoutes.html#/s:13SwiftyDropbox11FilesRoutesC10listFolderAA10RpcRequestCyAA0C0C04ListF16ResultSerializerCAH0if5ErrorK0CGSS4path_Sb9recursiveSb16includeMediaInfoSb0O7DeletedSb0O24HasExplicitSharedMembersSb0O14MountedFolderss6UInt32VSg5limittF" target="_self"&gt;files.listFolder&lt;/A&gt;&amp;nbsp;documentation to apply those additional changes to your local state to get up to date.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"&lt;STRONG&gt;Question 2&lt;/STRONG&gt;: Is there are way of polling only for changes to a specific directory?"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;No, unfortunately&amp;nbsp;&lt;A href="https://dropbox.github.io/SwiftyDropbox/api-docs/latest/Classes/FilesRoutes.html#/s:13SwiftyDropbox11FilesRoutesC18listFolderLongpollAA10RpcRequestCyAA0C0C04ListfG16ResultSerializerCAH0jfg5ErrorL0CGSS6cursor_s6UInt64V7timeouttF" target="_self"&gt;files.listFolderLongPoll&lt;/A&gt;&amp;nbsp;will notify of changes in the account even if the changes only&amp;nbsp;occurred outside of the path originally specified in the path set in the original&amp;nbsp;&lt;A href="https://dropbox.github.io/SwiftyDropbox/api-docs/latest/Classes/FilesRoutes.html#/s:13SwiftyDropbox11FilesRoutesC10listFolderAA10RpcRequestCyAA0C0C04ListF16ResultSerializerCAH0if5ErrorK0CGSS4path_Sb9recursiveSb16includeMediaInfoSb0O7DeletedSb0O24HasExplicitSharedMembersSb0O14MountedFolderss6UInt32VSg5limittF" target="_self"&gt;files.listFolder&lt;/A&gt;&amp;nbsp;call. We'll consider that a feature request, but I don't know if/when that would be implemented. (It would be non-trivial due to the way these pieces of infrastructure work on the backend.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps, and thanks for the kind words about the support!&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2017 16:34:54 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/API-v2-Long-polling/m-p/247955#M14218</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2017-10-19T16:34:54Z</dc:date>
    </item>
    <item>
      <title>Re: API v2 - Long polling</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/API-v2-Long-polling/m-p/248141#M14233</link>
      <description>Cheers, that's awesome and makes a lot of sense. I did miss the metadata casting and did wonder "why on earth bother sending back metadata at all if the revision isn't in there?"&lt;BR /&gt;&lt;BR /&gt;I'm getting rid of code left, right and center and getting better performance into the bargain.&lt;BR /&gt;&lt;BR /&gt;I'm so glad I posted here!&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;&lt;BR /&gt;Frank</description>
      <pubDate>Fri, 20 Oct 2017 07:58:42 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/API-v2-Long-polling/m-p/248141#M14233</guid>
      <dc:creator>Frank R.15</dc:creator>
      <dc:date>2017-10-20T07:58:42Z</dc:date>
    </item>
  </channel>
</rss>

