Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions rmcl/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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])
Expand All @@ -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
Expand Down
7 changes: 6 additions & 1 deletion rmcl/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down