module Keybase::Local::KBFS

Represents an interface to KBFS.

Constants

KBFS_STATUS_FILE

The path to a hidden status file on KBFS. @note The presence of this file is used to determine whether or not the mountpoint

is actually KBFS or just a directory (since an accidental directory at the mountpoint
is unlikely to contain this file).

Public Class Methods

functional?() click to toggle source

@return [Boolean] whether or not KBFS is currently fully functional @note The criteria for being “functional” is as follows:

1. Keybase is running
2. KBFS is running
3. {KBFS_MOUNT} is mounted
# File lib/keybase/local/kbfs.rb, line 44
def functional?
  Local.running? && running? && mounted?
end
mounted?() click to toggle source

@return [Boolean] whether or not KBFS is currently mounted @note {mounted?} does not mean that KBFS is fully functional. For that, see

{functional?}
# File lib/keybase/local/kbfs.rb, line 35
def mounted?
  Sys::Filesystem.mounts.any? { |m| m.mount_point == Config::KBFS_MOUNT }
end
running?() click to toggle source

@return [Boolean] whether or not KBFS is currently running @note {running?} does not mean that KBFS is mounted. For that, see {mounted?}

# File lib/keybase/local/kbfs.rb, line 20
def running?
  if Gem.win_platform?
    !`tasklist | find "kbfsfuse.exe"`.empty?
  elsif RUBY_PLATFORM =~ /darwin/
    !`pgrep kbfs`.empty?
  else
    Dir["/proc/[0-9]*/comm"].any? do |comm|
      File.read(comm).chomp == "kbfsfuse" rescue false
    end
  end
end
status() click to toggle source

@return [OpenStruct] a struct mapping of the contents of {KBFS_STATUS_FILE} @raise [Exceptions::KBFSNotRunningError] if KBFS is not functional

# File lib/keybase/local/kbfs.rb, line 50
def status
  raise Exceptions::KBFSNotRunningError unless functional?
  JSON.parse File.read(KBFS_STATUS_FILE), object_class: OpenStruct
end