summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjessib <jessib@riseup.net>2014-01-13 10:22:24 -0800
committerjessib <jessib@riseup.net>2014-01-13 10:22:24 -0800
commita421fc0a1fc2af9c91f459c6cfe256909c618d8e (patch)
tree127fe60ba34d6ae691c222e070f09e1802f88119
parent638e6a83a923e61d8b320818a39befd62529ae1a (diff)
parenta4fa58013a97344a4af431c64b471211b020bea0 (diff)
Merge pull request #8 from azul/bugfix/fix-for-revisions-starting-above-1
Revisions sometimes start at 2 - work around this
-rw-r--r--lib/tapicero/user_database.rb7
-rw-r--r--lib/tapicero_daemon.rb18
2 files changed, 18 insertions, 7 deletions
diff --git a/lib/tapicero/user_database.rb b/lib/tapicero/user_database.rb
index 5266b4a..cf43d98 100644
--- a/lib/tapicero/user_database.rb
+++ b/lib/tapicero/user_database.rb
@@ -9,6 +9,13 @@ module Tapicero
@name = name
end
+ def prepare(config)
+ db.create
+ db.secure(config.options[:security])
+ db.add_design_docs
+ logger.info "Prepared storage " + name
+ end
+
def create
retry_request_once "Creating database" do
create_db
diff --git a/lib/tapicero_daemon.rb b/lib/tapicero_daemon.rb
index 2a43cae..23248e3 100644
--- a/lib/tapicero_daemon.rb
+++ b/lib/tapicero_daemon.rb
@@ -12,17 +12,21 @@ module Tapicero
users.created do |hash|
logger.debug "Created user " + hash['id']
- db = user_database(hash['id'])
- db.create
- db.secure(config.options[:security])
- db.add_design_docs
- logger.info "Prepared storage for " + hash['id']
+ user_database(hash['id']).prepare(config)
+ end
+
+ # Sometimes changes log starts with rev 2. So the
+ # detection of is currently not working properly
+ # Working around this until a new version of
+ # couchrest changes takes this into account.
+ users.updated do |hash|
+ logger.debug "Updated user " + hash['id']
+ user_database(hash['id']).prepare(config)
end
users.deleted do |hash|
logger.debug "Deleted user " + hash['id']
- db = user_database(hash['id'])
- db.destroy
+ user_database(hash['id']).destroy
end
users.listen