[CalendarServer-changes] [14503] CalendarServer/trunk/txdav/base/datastore/subpostgres.py

source_changes at macosforge.org source_changes at macosforge.org
Wed Mar 4 12:25:44 PST 2015


Revision: 14503
          http://trac.calendarserver.org//changeset/14503
Author:   wsanchez at apple.com
Date:     2015-03-04 12:25:44 -0800 (Wed, 04 Mar 2015)
Log Message:
-----------
Fix up pg8000 connect code to deal with path to socket dir.

Modified Paths:
--------------
    CalendarServer/trunk/txdav/base/datastore/subpostgres.py

Modified: CalendarServer/trunk/txdav/base/datastore/subpostgres.py
===================================================================
--- CalendarServer/trunk/txdav/base/datastore/subpostgres.py	2015-03-04 20:04:24 UTC (rev 14502)
+++ CalendarServer/trunk/txdav/base/datastore/subpostgres.py	2015-03-04 20:25:44 UTC (rev 14503)
@@ -355,8 +355,22 @@
         kwargs = dict(database=databaseName)
 
         if self.host.startswith("/"):
+            # We're using a socket file
+            socketFP = CachingFilePath(self.host)
+
+            if socketFP.isdir():
+                # We have been given the directory, not the actual socket file
+                socketFP = socketFP.child(
+                    ".s.PGSQL.{}".format(self.port if self.port else 5432)
+                )
+
+            if not socketFP.isSocket():
+                raise InternalDataStoreError(
+                    "No such socket file: {}".format(socketFP.path)
+                )
+
             kwargs["host"] = None
-            kwargs["unix_sock"] = self.host
+            kwargs["unix_sock"] = socketFP.path
         else:
             kwargs["host"] = self.host
             kwargs["unix_sock"] = None
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150304/09754a25/attachment.html>


More information about the calendarserver-changes mailing list