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
-
.functional? ⇒ Boolean
Whether or not KBFS is currently fully functional.
-
.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
permalink .functional? ⇒ Boolean
The criteria for being "functional" is as follows:
- Keybase is running
- KBFS is running
- Config::KBFS_MOUNT is mounted
Returns whether or not KBFS is currently fully functional.
44 45 46 |
# File 'lib/keybase/local/kbfs.rb', line 44 def functional? Local.running? && running? && mounted? end |
permalink .mounted? ⇒ Boolean
mounted? does not mean that KBFS is fully functional. For that, see functional?
Returns whether or not KBFS is currently mounted.
35 36 37 |
# File 'lib/keybase/local/kbfs.rb', line 35 def mounted? Sys::Filesystem.mounts.any? { |m| m.mount_point == Config::KBFS_MOUNT } end |
permalink .running? ⇒ Boolean
20 21 22 23 24 25 26 27 28 29 30 |
# 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 |
permalink .status ⇒ OpenStruct
Returns a struct mapping of the contents of KBFS_STATUS_FILE.
50 51 52 53 |
# 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 |