mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-01 10:05:50 +00:00
Small refactoring for http storage
This commit is contained in:
parent
f565cd43a9
commit
2656ac7a92
2 changed files with 8 additions and 8 deletions
|
|
@ -107,7 +107,7 @@ def test_list(monkeypatch):
|
|||
|
||||
for href, etag in s.list():
|
||||
item, etag2 = s.get(href)
|
||||
assert item.uid is None
|
||||
assert item.uid is not None
|
||||
assert etag2 == etag
|
||||
found_items[item.raw.strip()] = href
|
||||
|
||||
|
|
@ -116,6 +116,6 @@ def test_list(monkeypatch):
|
|||
|
||||
for href, etag in s.list():
|
||||
item, etag2 = s.get(href)
|
||||
assert item.uid is None
|
||||
assert item.uid is not None
|
||||
assert etag2 == etag
|
||||
assert found_items[item.raw.strip()] == href
|
||||
|
|
|
|||
|
|
@ -153,13 +153,13 @@ class HttpStorage(Storage):
|
|||
self._items.clear()
|
||||
for i, item in enumerate(split_collection(r.text.splitlines())):
|
||||
item = Item(u'\n'.join(item), needs_uid=False)
|
||||
etag = hashlib.sha256(item.raw.encode('utf-8')).hexdigest()
|
||||
if item.uid is None:
|
||||
item.uid = i
|
||||
self._items[item.uid] = item
|
||||
item.uid = etag
|
||||
self._items[item.uid] = item, etag
|
||||
|
||||
for uid, item in self._items.items():
|
||||
yield uid, hashlib.sha256(item.raw.encode('utf-8')).hexdigest()
|
||||
for href, (item, etag) in self._items.items():
|
||||
yield href, etag
|
||||
|
||||
def get(self, href):
|
||||
x = self._items[href]
|
||||
return x, hashlib.sha256(x.raw.encode('utf-8')).hexdigest()
|
||||
return self._items[href]
|
||||
|
|
|
|||
Loading…
Reference in a new issue