From 5f48f8d7166ae0cc068e2b90a3ea89ac1a43c48e Mon Sep 17 00:00:00 2001 From: dormando Date: Tue, 15 May 2012 16:08:32 -0700 Subject: [PATCH] size arg check from tomas doran --- lib/MogileFS/Worker/Query.pm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/MogileFS/Worker/Query.pm b/lib/MogileFS/Worker/Query.pm index 3242131..5f8f41f 100644 --- a/lib/MogileFS/Worker/Query.pm +++ b/lib/MogileFS/Worker/Query.pm @@ -215,6 +215,8 @@ sub cmd_create_open { my $dmid = $args->{dmid}; my $key = $args->{key} || ""; my $multi = $args->{multi_dest} ? 1 : 0; + my $size = $args->{size} || undef; # Size is optional at create time, + # but used to grep devices if available # optional profiling of stages, if $args->{debug_profile} my @profpoints; # array of [point,hires-starttime] @@ -253,6 +255,10 @@ sub cmd_create_open { @devices = sort_devs_by_freespace(Mgd::device_factory()->get_all); } + if ($size) { + @devices = grep { ($_->mb_free * 1024*1024) > $size } @devices; + } + # find suitable device(s) to put this file on. my @dests; # MogileFS::Device objects which are suitable -- 2.11.4.GIT