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
-
.mounted? ⇒ Boolean
Whether or not KBFS is currently mounted.
-
.running? ⇒ Boolean
Whether or not KBFS is currently running.
-
.status ⇒ OpenStruct
A struct mapping of the contents of KBFS_STATUS_FILE.
Class Method Details
.mounted? ⇒ Boolean
Note:
The criteria for being mounted is as follows:
- Keybase is running
- KBFS is running
- KBFS_STATUS_FILE exists
Returns 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
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 |
.status ⇒ OpenStruct
Returns a struct mapping of the contents of KBFS_STATUS_FILE.
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 |