Ejemplo n.º 1
0
    def start_sync(self):
        """
        sync my onedrive note to mysql keep sync

        """

        sync_delta = mysqldatabase.get_last_delta_token()
        
        last_token = ''
        if sync_delta != None :
            last_token = sync_delta.delta_token
            self._try_sync_last_failed(sync_delta.item_content) 

        collection_page = self._get_item_changes(last_token)


        item_content_list = []
        for item in collection_page:
            if item.folder != None: continue

            info = self._download_to_temp(item)

            if info is None: continue

            item_content = info[6]
            item_content_list.append(item_content)

            mysqldatabase.addNote(info[0],info[1],info[2],info[3],info[4],info[5],0)

        # print(item_content_list)
        mysqldatabase.add_sync_delta(collection_page.token,item_content_list)
Ejemplo n.º 2
0
    def _try_sync_last_failed(self,item_content):
        """
        try again for the last failed  files
        """
        import json
        print('try sync last failed item')

        # print(repr(item_content))
        item_json = json.loads(item_content)

        for item in item_json:
            issuccess = item['issuccess']
            item_id = item['id']
            if not issuccess:

                request_item = self.client.item(drive = 'me', id = item_id) .request().get()
                
                print('starting try last failed item: ' + request_item.name.encode('utf-8'))
                info = self._download_to_temp(request_item) 

                mysqldatabase.addNote(info[0],info[1],info[2],info[3],info[4],info[5],0)