Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Commit

Permalink
[watcher] Workaround for API problem OneDrive/onedrive-sdk-python#93 .
Browse files Browse the repository at this point in the history
Signed-off-by: Xiangyu Bu <[email protected]>
  • Loading branch information
xybu committed Jan 20, 2017
1 parent 9b57683 commit ce9eb2c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion onedrived/od_tasks/upload_file.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
import os

import onedrivesdk
import onedrivesdk.error

from . import update_mtime
Expand Down Expand Up @@ -28,7 +29,10 @@ def __repr__(self):
return type(self).__name__ + '(%s)' % self.local_abspath

def update_progress(self, curr_part, total_part):
logging.debug('Uploading file "%s": Part %d / %d.', self.local_abspath, curr_part, total_part)
if curr_part == total_part:
logging.debug('All %d parts of file "%s" have been uploaded.', total_part, self.local_abspath)
else:
logging.debug('Uploading file "%s": Part %d / %d.', self.local_abspath, curr_part + 1, total_part)

def handle(self):
logging.info('Uploading file "%s" to OneDrive.', self.local_abspath)
Expand All @@ -47,6 +51,8 @@ def handle(self):
item_request = self.repo.authenticator.client.item(drive=self.repo.drive.id, path=self.rel_path)
returned_item = item_request_call(self.repo, item_request.upload_async,
local_path=self.local_abspath, upload_status=self.update_progress)
if not isinstance(returned_item, onedrivesdk.Item):
returned_item = onedrivesdk.Item(returned_item._prop_dict)
self.update_timestamp_and_record(returned_item, item_stat)
self.task_pool.release_path(self.local_abspath)
logging.info('Finished uploading file "%s".', self.local_abspath)
Expand Down

0 comments on commit ce9eb2c

Please sign in to comment.