Make dir_empty? method use Redis metadata

This commit is contained in:
Garret Alfert
2016-01-29 16:45:17 +01:00
parent 573dadf365
commit 7084a50d1b
2 changed files with 14 additions and 21 deletions

View File

@@ -453,8 +453,12 @@ module RemoteStorage
end
def dir_empty?(user, dir)
do_get_request("#{container_url_for(user)}/?format=plain&limit=1&path=#{escape(dir)}/") do |res|
return res.headers[:content_length] == "0"
if directory_backend(user).match /new/
redis.smembers("rs_meta:#{user}:#{dir}/:items").empty?
else
do_get_request("#{container_url_for(user)}/?format=plain&limit=1&path=#{escape(dir)}/") do |res|
return res.headers[:content_length] == "0"
end
end
end