Skip to content

Commit 31ead4c

Browse files
committed
refactor: lock related code(wip); fix a litmus warning, pass a litmus warning
1 parent 1eac465 commit 31ead4c

10 files changed

Lines changed: 879 additions & 309 deletions

File tree

asgi_webdav/constants.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,10 +374,11 @@ def __repr__(self) -> str:
374374

375375

376376
# Lock ---
377-
# --- lock:request
377+
# --- lock:request:header
378378
class DAVRequestIfConditionType(IntEnum):
379379
TOKEN = auto()
380380
ETAG = auto()
381+
NO_LOCK = auto() # for: Not <DAV:no-lock>
381382

382383

383384
@dataclass(slots=True)
@@ -398,6 +399,13 @@ class DAVRequestIf:
398399
conditions: list[list[DAVRequestIfCondition]]
399400

400401

402+
# --- lock:request:body
403+
@dataclass(slots=True)
404+
class DAVRequestBodyLock:
405+
scope: DAVLockScope
406+
owner: str
407+
408+
401409
# --- lock:locker
402410
DAVLockTimeoutMaxValue = 2 ^ 32 - 1 # TODO: move into config
403411

asgi_webdav/lock.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,6 @@ async def is_valid_lock_token(self, token: UUID, path: DAVPath) -> bool:
157157
async def get_info_by_path(self, path: DAVPath) -> list[DAVLockInfo]:
158158
"""获取指定路径的所有锁信息"""
159159
async with self.lock:
160-
if path not in self.path2token_map:
161-
return []
162-
163160
result: list[DAVLockInfo] = list()
164161
for token in self.path2token_map.get_tokens(path):
165162
info = self._get_lock_info(token)
@@ -199,6 +196,6 @@ async def _release_by_path(self, path: DAVPath) -> None:
199196

200197
def __repr__(self) -> str:
201198
s = "{}\n{}".format(
202-
pprint.pformat(self.path2token_map), pprint.pformat(self.lock_map)
199+
pprint.pformat(self.path2token_map.data), pprint.pformat(self.lock_map)
203200
)
204201
return s

0 commit comments

Comments
 (0)