$56 GRAYBYTE WORDPRESS FILE MANAGER $49

SERVER : premium201.web-hosting.com #1 SMP Wed Mar 26 12:08:09 UTC 2025
SERVER IP : 172.67.217.254 | ADMIN IP 216.73.216.36
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/opt/alt/ruby33/share/gems/gems/bundler-2.5.22/lib/bundler/compact_index_client/

HOME
Current File : /opt/alt/ruby33/share/gems/gems/bundler-2.5.22/lib/bundler/compact_index_client//cache.rb
# frozen_string_literal: true

require_relative "gem_parser"

module Bundler
  class CompactIndexClient
    class Cache
      attr_reader :directory

      def initialize(directory, fetcher = nil)
        @directory = Pathname.new(directory).expand_path
        @updater = Updater.new(fetcher) if fetcher
        @mutex = Thread::Mutex.new
        @endpoints = Set.new

        @info_root = mkdir("info")
        @special_characters_info_root = mkdir("info-special-characters")
        @info_etag_root = mkdir("info-etags")
      end

      def names
        fetch("names", names_path, names_etag_path)
      end

      def versions
        fetch("versions", versions_path, versions_etag_path)
      end

      def info(name, remote_checksum = nil)
        path = info_path(name)

        if remote_checksum && remote_checksum != SharedHelpers.checksum_for_file(path, :MD5)
          fetch("info/#{name}", path, info_etag_path(name))
        else
          Bundler::CompactIndexClient.debug { "update skipped info/#{name} (#{remote_checksum ? "versions index checksum is nil" : "versions index checksum matches local"})" }
          read(path)
        end
      end

      def reset!
        @mutex.synchronize { @endpoints.clear }
      end

      private

      def names_path = directory.join("names")
      def names_etag_path = directory.join("names.etag")
      def versions_path = directory.join("versions")
      def versions_etag_path = directory.join("versions.etag")

      def info_path(name)
        name = name.to_s
        # TODO: converge this into the info_root by hashing all filenames like info_etag_path
        if /[^a-z0-9_-]/.match?(name)
          name += "-#{SharedHelpers.digest(:MD5).hexdigest(name).downcase}"
          @special_characters_info_root.join(name)
        else
          @info_root.join(name)
        end
      end

      def info_etag_path(name)
        name = name.to_s
        @info_etag_root.join("#{name}-#{SharedHelpers.digest(:MD5).hexdigest(name).downcase}")
      end

      def mkdir(name)
        directory.join(name).tap do |dir|
          SharedHelpers.filesystem_access(dir) do
            FileUtils.mkdir_p(dir)
          end
        end
      end

      def fetch(remote_path, path, etag_path)
        if already_fetched?(remote_path)
          Bundler::CompactIndexClient.debug { "already fetched #{remote_path}" }
        else
          Bundler::CompactIndexClient.debug { "fetching #{remote_path}" }
          @updater&.update(remote_path, path, etag_path)
        end

        read(path)
      end

      def already_fetched?(remote_path)
        @mutex.synchronize { [email protected]?(remote_path) }
      end

      def read(path)
        return unless path.file?
        SharedHelpers.filesystem_access(path, :read, &:read)
      end
    end
  end
end


Current_dir [ NOT WRITEABLE ] Document_root [ NOT WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
13 May 2025 8.40 AM
root / linksafe
0755
cache.rb
2.749 KB
24 Apr 2025 7.57 AM
root / linksafe
0644
cache_file.rb
4.558 KB
24 Apr 2025 7.57 AM
root / linksafe
0644
gem_parser.rb
1.031 KB
24 Apr 2025 7.57 AM
root / linksafe
0644
parser.rb
2.634 KB
24 Apr 2025 7.57 AM
root / linksafe
0644
updater.rb
4.349 KB
24 Apr 2025 7.57 AM
root / linksafe
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025 CONTACT ME
Static GIF