summaryrefslogtreecommitdiff
path: root/lib/rbot
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rbot')
-rw-r--r--lib/rbot/registry.rb10
-rw-r--r--lib/rbot/registry/daybreak.rb5
-rw-r--r--lib/rbot/registry/dbm.rb11
-rw-r--r--lib/rbot/registry/sqlite.rb5
-rw-r--r--lib/rbot/registry/tc.rb5
5 files changed, 18 insertions, 18 deletions
diff --git a/lib/rbot/registry.rb b/lib/rbot/registry.rb
index 4fd5f77c..70b450ac 100644
--- a/lib/rbot/registry.rb
+++ b/lib/rbot/registry.rb
@@ -98,6 +98,8 @@ class Registry
# Abstract database accessor (a hash-like interface).
class AbstractAccessor
+ attr_reader :filename
+
# lets the user define a recovery procedure in case the Marshal
# deserialization fails, it might be manually recover data.
# NOTE: weird legacy stuff, used by markov plugin (WTH?)
@@ -187,13 +189,13 @@ class Registry
# Forces flush/sync the database on disk.
def flush
return unless @registry
- @registry.flush
+ # if not supported by the database, close/reopen:
+ close
+ registry
end
- # Should optimize/vacuum the database.
+ # Should optimize/vacuum the database. (if supported)
def optimize
- return unless @registry
- @registry.optimize
end
# Closes the database.
diff --git a/lib/rbot/registry/daybreak.rb b/lib/rbot/registry/daybreak.rb
index 6058b408..233c3a0d 100644
--- a/lib/rbot/registry/daybreak.rb
+++ b/lib/rbot/registry/daybreak.rb
@@ -24,6 +24,11 @@ class Registry
@registry ||= Daybreak::DB.new(@filename)
end
+ def flush
+ return unless @registry
+ @registry.flush
+ end
+
def optimize
return unless @registry
@registry.compact
diff --git a/lib/rbot/registry/dbm.rb b/lib/rbot/registry/dbm.rb
index a13cb8ce..9c0304a9 100644
--- a/lib/rbot/registry/dbm.rb
+++ b/lib/rbot/registry/dbm.rb
@@ -23,21 +23,10 @@ class Registry
@registry ||= DBM.open(@filename, 0666, DBM::WRCREAT)
end
- def flush
- return if !@registry
- # ruby dbm has no flush, so we close/reopen :(
- close
- registry
- end
-
def dbexists?
not Dir.glob(@filename + '.*').empty?
end
- def optimize
- # unsupported!
- end
-
end
end # Registry
diff --git a/lib/rbot/registry/sqlite.rb b/lib/rbot/registry/sqlite.rb
index 89e7d78c..1af5d242 100644
--- a/lib/rbot/registry/sqlite.rb
+++ b/lib/rbot/registry/sqlite.rb
@@ -29,10 +29,9 @@ class Registry
@registry
end
- def flush
- end
-
def optimize
+ return unless @registry
+ @registry.execute('VACUUM')
end
def [](key)
diff --git a/lib/rbot/registry/tc.rb b/lib/rbot/registry/tc.rb
index 63bfdf78..4e248f42 100644
--- a/lib/rbot/registry/tc.rb
+++ b/lib/rbot/registry/tc.rb
@@ -36,6 +36,11 @@ class Registry
@registry.sync
end
+ def optimize
+ return unless @registry
+ @registry.optimize
+ end
+
end
end # Registry