[Calypso] [PATCH] fix description in absence of .git/description, Collection.urlpath
chrysn
chrysn at fsfe.org
Wed Feb 3 14:37:07 PST 2016
.git/description is absent, for example, when several (or all)
collections are stored in a combined git repository.
in order to have a sensible default for descriptions, collections now
retain their url paths (previously, only the absolute file system path
was stored).
---
calypso/webdav.py | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/calypso/webdav.py b/calypso/webdav.py
index f6b84ab..12a9817 100644
--- a/calypso/webdav.py
+++ b/calypso/webdav.py
@@ -233,11 +233,12 @@ class Collection(object):
"""Internal collection class."""
def get_description(self):
- f = codecs.open(os.path.join(self.path, ".git/description"), encoding='utf-8')
try:
- return f.read()
- finally:
- f.close()
+ f = codecs.open(os.path.join(self.path, ".git/description"), encoding='utf-8')
+ except IOError:
+ # .git/description is not present eg when the complete server is a single git repo
+ return self.urlpath
+ return f.read()
def read_file(self, path):
text = codecs.open(path,encoding='utf-8').read()
@@ -304,6 +305,7 @@ class Collection(object):
self.log = logging.getLogger(__name__)
self.encoding = "utf-8"
+ self.urlpath = path
self.owner = paths.url_to_owner(path)
self.path = paths.url_to_file(path)
self.pattern = os.path.join(self.path, "*")
--
2.7.0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://keithp.com/pipermail/calypso/attachments/20160203/0908520e/attachment.sig>
More information about the Calypso
mailing list