Module: Keybase::Local::KBFS

Defined in:
lib/keybase/local/kbfs.rb

Overview

Represents an interface to KBFS.

Constant Summary collapse

KBFS_STATUS_FILE =
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).

The path to a hidden status file on KBFS.

File.join Config::KBFS_MOUNT, ".kbfs_status"

Class Method Summary collapse

Class Method Details

.mounted?Boolean

Note:

The criteria for being mounted is as follows:

  1. Keybase is running
  2. KBFS is running
  3. KBFS_STATUS_FILE exists

Returns whether or not KBFS is currently mounted.

Returns:

  • (Boolean)

    whether or not KBFS is currently mounted



36
37
38
39
40
# File 'lib/keybase/local/kbfs.rb', line 36

def mounted?
  return false unless Local.running?
  return false unless running?
  File.exist? KBFS_STATUS_FILE
end

.running?Boolean

Note:

running? does not mean that KBFS is mounted. For that, see mounted?

Returns whether or not KBFS is currently running.

Returns:

  • (Boolean)

    whether or not KBFS is currently running



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/keybase/local/kbfs.rb', line 19

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

.statusOpenStruct

Returns a struct mapping of the contents of KBFS_STATUS_FILE.

Returns:

Raises:



44
45
46
47
# File 'lib/keybase/local/kbfs.rb', line 44

def status
  raise Exceptions::KBFSNotRunningError unless mounted?
  JSON.parse File.read(KBFS_STATUS_FILE), object_class: OpenStruct
end