From 7988560d75a681089eabc2a0929bcdc1e5a3ae2f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 26 Oct 2010 09:55:35 -0600 Subject: [PATCH] SONY driver: Fix bug when adding records to empty cacheExt.xml --- src/calibre/devices/prs505/sony_cache.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/calibre/devices/prs505/sony_cache.py b/src/calibre/devices/prs505/sony_cache.py index 15245d3cd5..17eea3a27c 100644 --- a/src/calibre/devices/prs505/sony_cache.py +++ b/src/calibre/devices/prs505/sony_cache.py @@ -573,7 +573,10 @@ class XMLCache(object): ans = root.makeelement('{%s}text'%namespace, attrib=attrib, nsmap=root.nsmap) ans.tail = '\n' - root[-1].tail = '\n' + '\t' + if len(root) > 0: + root[-1].tail = '\n\t' + else: + root.text = '\n\t' root.append(ans) if thumbnail and thumbnail[-1]: ans.text = '\n' + '\t\t'