xybu / onedrived-dev

A Microsoft OneDrive client for Linux, written in Python3.
https://github.com/xybu/onedrived-dev
MIT License
705 stars 78 forks source link

Fast way to pull changes from remote to local? #8

Open xybu opened 7 years ago

xybu commented 7 years ago

There are a few ways to achieve this:

  1. By checking view.recent API. I'm under an impression that it only lists document files. Need to double check. Also there's a bug in SDK at https://github.com/OneDrive/onedrive-sdk-python/issues/92.

  2. By using webhooks (https://dev.onedrive.com/webhooks/webhooks.htm). The official SDK does not implement it. What if the client is not reachable from OneDrive server (e.g., client behind NAT)?

    1. The code to handle webhook notifications should be the same. What differs is the part to receive them.
    2. Spin up a direct HTTP(s) server if client has public IP.
    3. Relay the requests using ngrok.
    4. Create some relay server that (1) receives all notifications from OneDrive server, and (2) establish connection with clients, and relay the notifications to proper user. Issues for this approach include lacking of infrastructure (relay servers), delay (servers not globally distributed), and connection management (clients create permanent TCP/TLS connections to relay server).
  3. By checking the delta pages view.delta on all directories (https://dev.onedrive.com/items/view_delta.htm). Basically a faster polling.

xybu commented 7 years ago

Will use webhook event to trigger delta update.

Update: view.delta (https://dev.onedrive.com/items/view_delta.htm) provides good way to obtain a snapshot of metadata of remote repo items, but the problem is that those information is not reliable -- for example, the size field -- so we have to keep a local database anyway. For now webhook update may just trigger a deep merge. We can further optimize the subroutines of deep merge to make it faster.

xybu commented 7 years ago

Outstanding issues with webhooks in SDK:

  1. Error with SubscriptionRequest.update() (https://github.com/OneDrive/onedrive-sdk-python/issues/95): workaround by patching the SDK.

  2. No available method in SDK to create subscriptions (https://github.com/OneDrive/onedrive-sdk-python/issues/94): workaround by creating the API call using existing SDK classes.

jamespatersonMOA commented 7 years ago

hi! any chance you could share the code for the workarounds please?