command-t/ruby/command-t/scanner/file_scanner/watchman_file_scanner.rb
# Exception raised when Watchman is unavailable or unable to process the
# requested path.
Exception raised when Watchman is unavailable or unable to process the
requested path.
Exception raised when Watchman is unavailable or unable to process the requested path .
def paths
        @paths[@path] ||= begin
          ensure_cache_under_limit
          sockname = Watchman::Utils.load(
            %x{watchman --output-encoding=bser get-sockname}
          )['sockname']
          raise WatchmanUnavailable unless $?.exitstatus.zero?
          UNIXSocket.open(sockname) do |socket|
            root = Pathname.new(@path).realpath.to_s
            roots = Watchman::Utils.query(['watch-list'], socket)['roots']
            if !roots.include?(root)
              result = Watchman::Utils.query(['watch', root], socket)
              raise WatchmanUnavailable if result.has_key?('error')
            end
            query = ['query', root, {
              'expression' => ['type', 'f'],
              'fields'     => ['name'],
            }]
            paths = Watchman::Utils.query(query, socket)
            raise WatchmanUnavailable if paths.has_key?('error')
            @paths[@path] = paths['files']
          end
        end
        @paths[@path]
      rescue Errno::ENOENT, WatchmanUnavailable
        super
      end
def paths @paths [ @path ] ||= begin ensure_cache_under_limit sockname = Watchman :: Utils . load ( %x{ watchman --output-encoding=bser get-sockname } ) [ 'sockname' ] raise WatchmanUnavailable unless $? . exitstatus . zero? UNIXSocket . open ( sockname ) do | socket | root = Pathname . new ( @path ) . realpath . to_s roots = Watchman :: Utils . query ( [ 'watch-list' ] , socket ) [ 'roots' ] if ! roots . include? ( root ) result = Watchman :: Utils . query ( [ 'watch' , root ] , socket ) raise WatchmanUnavailable if result . has_key? ( 'error' ) end query = [ 'query' , root , { 'expression' => [ 'type' , 'f' ] , 'fields' => [ 'name' ] , } ] paths = Watchman :: Utils . query ( query , socket ) raise WatchmanUnavailable if paths . has_key? ( 'error' ) @paths [ @path ] = paths [ 'files' ] end end @paths [ @path ] rescue Errno :: ENOENT , WatchmanUnavailable super end
Exception raised when Watchman is unavailable or unable to process the
requested path.
Exception raised when Watchman is unavailable or unable to process the requested path .
# this path isn't being watched yet; try to set up watch # root_restrict_files setting may prevent Watchman from working # could return error if watch is removed # watchman executable not present, or unable to fulfil request