about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2016-11-26 08:06:50 +0000
committerEric Wong <e@80x24.org>2016-11-26 08:06:50 +0000
commit5e65897053f20fc6d09ab22448c43d7103c779f2 (patch)
tree05d5d5467c6255364b9a8cdebfa2dccd1f417516
parentaf91a075c10cfc7dd6f7e04c55ae2b14dc25d1ea (diff)
downloaddtas-5e65897053f20fc6d09ab22448c43d7103c779f2.tar.gz
This ought to avoid busy DB errors.
-rw-r--r--lib/dtas/mlib.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/dtas/mlib.rb b/lib/dtas/mlib.rb
index 09856ee..a01a136 100644
--- a/lib/dtas/mlib.rb
+++ b/lib/dtas/mlib.rb
@@ -298,8 +298,10 @@ class DTAS::Mlib # :nodoc:
       dir = dir_vivify(@pwd.split(%r{/+}n), st.ctime.to_i)
       dir_id = dir[:id]
 
-      @db[:nodes].where(parent_id: dir_id).each do |node|
-        File.exist?(node[:name]) or remove_entry(node)
+      @db.transaction do
+        @db[:nodes].where(parent_id: dir_id).each do |node|
+          File.exist?(node[:name]) or remove_entry(node)
+        end
       end
 
       Dir.foreach('.', encoding: Encoding::BINARY) do |x|