aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorTim Oram2012-06-22 02:30:00 -0230
committerAdam Vandenberg2012-06-23 10:18:16 -0700
commit3147dd134a6e919c974b4a8abc93338d489cc31a (patch)
tree67588ec3b48e6d9076be76e6509684c0d43d4c45 /Library
parent0d2e26fc585c8b82f5b7c50bf98f0e0b89a690f2 (diff)
downloadbrew-3147dd134a6e919c974b4a8abc93338d489cc31a.tar.bz2
doctor: rewrite Volume class to fix issue with google update engine
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cmd/doctor.rb40
1 files changed, 26 insertions, 14 deletions
diff --git a/Library/Homebrew/cmd/doctor.rb b/Library/Homebrew/cmd/doctor.rb
index c2131445a..8aa229b28 100644
--- a/Library/Homebrew/cmd/doctor.rb
+++ b/Library/Homebrew/cmd/doctor.rb
@@ -3,25 +3,37 @@ require 'cmd/missing'
class Volumes
def initialize
- @volumes = []
- raw_mounts=`/sbin/mount`
- raw_mounts.split("\n").each do |line|
- case line
- when /^(.+) on (\S+) \(/
- @volumes << [$1, $2]
- end
- end
- # Sort volumes by longest path prefix first
- @volumes.sort! {|a,b| b[1].length <=> a[1].length}
+ @volumes = get_mounts
end
def which path
- @volumes.each_index do |i|
- vol = @volumes[i]
- return i if vol[1].start_with? path.to_s
+ vols = get_mounts path
+
+ # no volume found
+ if vols.empty?
+ return -1
+ end
+
+ vol_index = @volumes.index(vols[0])
+ # volume not found in volume list
+ if vol_index.nil?
+ return -1
end
+ return vol_index
+ end
- return -1
+ def get_mounts path=nil
+ vols = []
+ # get the volume of path, if path is nil returns all volumes
+ raw_df = `/bin/df -P #{path}`
+ raw_df.split("\n").each do |line|
+ case line
+ # regex matches: /dev/disk0s2 489562928 440803616 48247312 91% /
+ when /^(.*)\s+([0-9]+)\s+([0-9]+)\s+([0-9]+)\s+([0-9]{1,3}\%)\s+(.*)/
+ vols << $6
+ end
+ end
+ return vols
end
end