mirror of
https://github.com/Kozea/Radicale.git
synced 2025-06-26 16:45:52 +00:00
Give an UID if none has already been set
This commit is contained in:
parent
020239e168
commit
dd6063ccb6
1 changed files with 12 additions and 6 deletions
|
@ -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,14 +98,19 @@ 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 "\nX-RADICALE-NAME:" in text:
|
if self._name:
|
||||||
for line in unfold(self.text):
|
if "\nX-RADICALE-NAME:" in text:
|
||||||
if line.startswith("X-RADICALE-NAME:"):
|
for line in unfold(self.text):
|
||||||
self.text = self.text.replace(
|
if line.startswith("X-RADICALE-NAME:"):
|
||||||
line, "X-RADICALE-NAME:%s" % self._name)
|
self.text = self.text.replace(
|
||||||
|
line, "X-RADICALE-NAME:%s" % self._name)
|
||||||
|
else:
|
||||||
|
self.text = self.text.replace(
|
||||||
|
"\nUID:", "\nX-RADICALE-NAME:%s\nUID:" % self._name)
|
||||||
else:
|
else:
|
||||||
|
self._name = str(uuid.uuid4())
|
||||||
self.text = self.text.replace(
|
self.text = self.text.replace(
|
||||||
"\nUID:", "\nX-RADICALE-NAME:%s\nUID:" % self._name)
|
"\nEND:", "\nUID:%s\nEND:" % self._name)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def etag(self):
|
def etag(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue