diff --git a/rmcl/api.py b/rmcl/api.py index c1fe735..5e4138b 100644 --- a/rmcl/api.py +++ b/rmcl/api.py @@ -23,8 +23,7 @@ AuthError, DocumentNotFound, ApiError,) -from .const import (RFC3339Nano, - USER_AGENT, +from .const import (USER_AGENT, DEVICE_TOKEN_URL, USER_TOKEN_URL, USER_TOKEN_VALIDITY, @@ -315,7 +314,6 @@ async def update_metadata(self, item: items.Item): # Copy the metadata so that the object gets out of date and will be refreshed metadata = item._metadata.copy() metadata['Version'] += 1 - metadata["ModifiedClient"] = now().strftime(RFC3339Nano) res = await self.request("PUT", "/document-storage/json/2/upload/update-status", body=[metadata]) @@ -341,6 +339,7 @@ async def upload(self, item, contents): if up_res.status_code >= 400: log.error(f"Upload failed with status {up_res.status_code}") raise ApiError(f"Upload failed with status {up_res.status_code}", response=up_res) + item.mtime = now() await self.update_metadata(item) @staticmethod diff --git a/rmcl/items.py b/rmcl/items.py index e6c320c..b689db7 100644 --- a/rmcl/items.py +++ b/rmcl/items.py @@ -15,7 +15,7 @@ render = None from . import api -from .const import ROOT_ID, TRASH_ID, FileType +from .const import ROOT_ID, TRASH_ID, FileType, RFC3339Nano from . import datacache from .exceptions import DocumentNotFound, VirtualItemError from .sync import add_sync @@ -117,6 +117,10 @@ def parent(self, value): def mtime(self): return parse_datetime(self._metadata.get('ModifiedClient')) + @mtime.setter + def mtime(self, value): + self._metadata['ModifiedClient'] = value.strftime(RFC3339Nano) + @property def virtual(self): return False @@ -201,6 +205,7 @@ async def delete(self): if folder.id == TRASH_ID: return await client.delete(self) self.parent = TRASH_ID + self.mtime = now() await client.update_metadata(self) @add_sync