Give an UID if none has already been set
This commit is contained in:
parent
020239e168
commit
dd6063ccb6
@ -31,6 +31,7 @@ import json
|
|||||||
import os
|
import os
|
||||||
import posixpath
|
import posixpath
|
||||||
import time
|
import time
|
||||||
|
import uuid
|
||||||
|
|
||||||
from radicale import config
|
from radicale import config
|
||||||
|
|
||||||
@ -97,6 +98,7 @@ class Item(object):
|
|||||||
self._name = line.replace("UID:", "").strip()
|
self._name = line.replace("UID:", "").strip()
|
||||||
# Do not break, a ``X-RADICALE-NAME`` can appear next
|
# Do not break, a ``X-RADICALE-NAME`` can appear next
|
||||||
|
|
||||||
|
if self._name:
|
||||||
if "\nX-RADICALE-NAME:" in text:
|
if "\nX-RADICALE-NAME:" in text:
|
||||||
for line in unfold(self.text):
|
for line in unfold(self.text):
|
||||||
if line.startswith("X-RADICALE-NAME:"):
|
if line.startswith("X-RADICALE-NAME:"):
|
||||||
@ -105,6 +107,10 @@ class Item(object):
|
|||||||
else:
|
else:
|
||||||
self.text = self.text.replace(
|
self.text = self.text.replace(
|
||||||
"\nUID:", "\nX-RADICALE-NAME:%s\nUID:" % self._name)
|
"\nUID:", "\nX-RADICALE-NAME:%s\nUID:" % self._name)
|
||||||
|
else:
|
||||||
|
self._name = str(uuid.uuid4())
|
||||||
|
self.text = self.text.replace(
|
||||||
|
"\nEND:", "\nUID:%s\nEND:" % self._name)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def etag(self):
|
def etag(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user