require 'fog' require 'digest/md5' module RightPublish module LocalStorage DEFAULT_LOCAL_CACHEDIR = '~/.rp_cache' STORAGE_KEY = :local_storage STORAGE_OPTIONS = { :cache_dir=>DEFAULT_LOCAL_CACHEDIR} def compute_md5(file) Digest::MD5.file(File.join(service.path_to(self.key), file.key)).hexdigest end def self.get_directories() Profile.log("Connecting to local cache.", :debug) conn = Fog::Storage.new( :provider=>"Local", :local_root=>Profile.config[STORAGE_KEY][:cache_dir] ) Profile.log("Attaching to local cache: [#{Profile.config[STORAGE_KEY][:cache_dir]}].", :debug) conn.directories.create(:key=>'.') unless File.exists? Profile.config[STORAGE_KEY][:cache_dir] local_dir = conn.directories.get('.') local_dir.extend(LocalStorage) local_dir end end RightPublish::StorageManager.register_storage(LocalStorage) end