mirror of
https://github.com/etesync/server
synced 2024-12-29 10:48:07 +00:00
More typing fixes.
This commit is contained in:
parent
6615b149c5
commit
a7fdb4a108
@ -56,6 +56,7 @@ class Collection(models.Model):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def content(self) -> "CollectionItemRevision":
|
def content(self) -> "CollectionItemRevision":
|
||||||
|
assert self.main_item is not None
|
||||||
return self.main_item.content
|
return self.main_item.content
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -107,6 +107,7 @@ class CollectionOut(CollectionCommon):
|
|||||||
def from_orm_context(cls: t.Type["CollectionOut"], obj: models.Collection, context: Context) -> "CollectionOut":
|
def from_orm_context(cls: t.Type["CollectionOut"], obj: models.Collection, context: Context) -> "CollectionOut":
|
||||||
member: models.CollectionMember = obj.members.get(user=context.user)
|
member: models.CollectionMember = obj.members.get(user=context.user)
|
||||||
collection_type = member.collectionType
|
collection_type = member.collectionType
|
||||||
|
assert obj.main_item is not None
|
||||||
ret = cls(
|
ret = cls(
|
||||||
collectionType=collection_type and bytes(collection_type.uid),
|
collectionType=collection_type and bytes(collection_type.uid),
|
||||||
collectionKey=bytes(member.encryptionKey),
|
collectionKey=bytes(member.encryptionKey),
|
||||||
@ -299,8 +300,8 @@ def process_revisions_for_item(item: models.CollectionItem, revision_data: Colle
|
|||||||
revision.stoken = stoken
|
revision.stoken = stoken
|
||||||
revision.save()
|
revision.save()
|
||||||
|
|
||||||
for chunk in chunks_objs:
|
for chunk2 in chunks_objs:
|
||||||
models.RevisionChunkRelation.objects.create(chunk=chunk, revision=revision)
|
models.RevisionChunkRelation.objects.create(chunk=chunk2, revision=revision)
|
||||||
return revision
|
return revision
|
||||||
|
|
||||||
|
|
||||||
@ -383,6 +384,7 @@ def item_create(item_model: CollectionItemIn, collection: models.Collection, val
|
|||||||
# We don't have to use select_for_update here because the unique constraint on current guards against
|
# We don't have to use select_for_update here because the unique constraint on current guards against
|
||||||
# the race condition. But it's a good idea because it'll lock and wait rather than fail.
|
# the race condition. But it's a good idea because it'll lock and wait rather than fail.
|
||||||
current_revision = instance.revisions.filter(current=True).select_for_update().first()
|
current_revision = instance.revisions.filter(current=True).select_for_update().first()
|
||||||
|
assert current_revision is not None
|
||||||
current_revision.current = None
|
current_revision.current = None
|
||||||
current_revision.save()
|
current_revision.save()
|
||||||
|
|
||||||
@ -523,8 +525,8 @@ def fetch_updates(
|
|||||||
|
|
||||||
new_stoken_obj = get_queryset_stoken(queryset)
|
new_stoken_obj = get_queryset_stoken(queryset)
|
||||||
new_stoken = new_stoken_obj and new_stoken_obj.uid
|
new_stoken = new_stoken_obj and new_stoken_obj.uid
|
||||||
stoken = stoken_rev and getattr(stoken_rev, "uid", None)
|
stoken_rev_uid = stoken_rev and getattr(stoken_rev, "uid", None)
|
||||||
new_stoken = new_stoken or stoken
|
new_stoken = new_stoken or stoken_rev_uid
|
||||||
|
|
||||||
context = Context(user, prefetch)
|
context = Context(user, prefetch)
|
||||||
return CollectionItemListResponse(
|
return CollectionItemListResponse(
|
||||||
|
Loading…
Reference in New Issue
Block a user