From ea25d27f240cacad4fac4a1bf97455aa03c4c8f5 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 6 Apr 2022 20:53:45 -0300 Subject: [PATCH 1/2] =?UTF-8?q?calcular=20el=20tama=C3=B1o=20a=20partir=20?= =?UTF-8?q?de=20deploy=20local?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/deploy_rsync.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/deploy_rsync.rb b/app/models/deploy_rsync.rb index c19d279b..b2ffba7c 100644 --- a/app/models/deploy_rsync.rb +++ b/app/models/deploy_rsync.rb @@ -13,7 +13,7 @@ class DeployRsync < Deploy # # @return [Integer] def size - deploy_local.build_stats.last.size + deploy_local.size end # Devolver el destino o lanzar un error si no está configurado From bb7c50e24b4fb9a9ce16666d53a77fc666a22506 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 6 Apr 2022 20:54:35 -0300 Subject: [PATCH 2/2] calcular el espacio una sola vez --- app/models/deploy_local.rb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/models/deploy_local.rb b/app/models/deploy_local.rb index 4fa588f5..1b661059 100644 --- a/app/models/deploy_local.rb +++ b/app/models/deploy_local.rb @@ -28,15 +28,17 @@ class DeployLocal < Deploy # Obtener el tamaño de todos los archivos y directorios (los # directorios son archivos :) def size - paths = [destination, File.join(destination, '**', '**')] + @size ||= begin + paths = [destination, File.join(destination, '**', '**')] - Dir.glob(paths).map do |file| - if File.symlink? file - 0 - else - File.size(file) - end - end.inject(:+) + Dir.glob(paths).map do |file| + if File.symlink? file + 0 + else + File.size(file) + end + end.inject(:+) + end end def destination