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

Commit

Permalink
[tasks] Fixed bug that size_local field of files is set to 0 after mo…
Browse files Browse the repository at this point in the history
…ve op.

Signed-off-by: Xiangyu Bu <[email protected]>
  • Loading branch information
xybu committed Jan 16, 2017
1 parent 06a41a8 commit 5d2f7aa
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion onedrived/od_tasks/move_item.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import os

import onedrivesdk.error
from onedrivesdk import Item, ItemReference
Expand Down Expand Up @@ -58,13 +59,14 @@ def handle(self):
# The routine assumes that the directory to save the new path exists remotely.
item_request = self.get_item_request()
try:
size = 0 if self.is_folder else os.stat(self.repo.local_root + self.new_relpath).st_size
item = item_request_call(self.repo, item_request.update, self._get_new_item())
# TODO: update all records or rebuild records after deletion?
# self.repo.delete_item(self.item_name, self.parent_relpath, self.is_folder)
self.repo.move_item(item_name=self.item_name, parent_relpath=self.parent_relpath,
new_name=self.new_name, new_parent_relpath=self.new_parent_relpath,
is_folder=self.is_folder)
self.repo.update_item(item, self.new_parent_relpath, 0)
self.repo.update_item(item, self.new_parent_relpath, size_local=size)
return True
except (onedrivesdk.error.OneDriveError, OSError) as e:
logging.error('Error moving item "%s" to "%s": %s.', self.rel_path, self.new_relpath, e)
Expand Down

0 comments on commit 5d2f7aa

Please sign in to comment.