From 5e65897053f20fc6d09ab22448c43d7103c779f2 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 26 Nov 2016 08:06:50 +0000 Subject: mlib: use transaction for removing stale entries This ought to avoid busy DB errors. --- lib/dtas/mlib.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/dtas') 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| -- cgit v1.2.3-24-ge0c7