Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store metadata with installed Casks. #3066

Merged
merged 1 commit into from
Dec 11, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/cask.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@ def self.nowstamp_metadata_path(container_path)
end
end

attr_reader :token
def initialize(token=self.class.token)
@token = token
attr_reader :token, :sourcefile_path
def initialize(sourcefile_path=nil)
@sourcefile_path = sourcefile_path
@token = self.class.token
end

def caskroom_path
Expand Down
17 changes: 17 additions & 0 deletions lib/cask/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def install(force=false)
download
extract_primary_container
install_artifacts
save_caskfile force
enable_accessibility_access
rescue StandardError => e
purge_versioned_files
Expand Down Expand Up @@ -217,6 +218,22 @@ def disable_accessibility_access
end
end

def save_caskfile(force=false)
timestamp = :now
create = true
savedir = @cask.metadata_subdir('Casks', timestamp, create)
if Dir.entries(savedir).size > 2
# should not happen
if force
savedir.rmtree
FileUtils.mkdir_p savedir
else
raise CaskAlreadyInstalledError.new(@cask)
end
end
FileUtils.copy(@cask.sourcefile_path, savedir) if @cask.sourcefile_path
end

def uninstall(force=false)
odebug "Cask::Installer.uninstall"
disable_accessibility_access
Expand Down
2 changes: 1 addition & 1 deletion lib/cask/source/path_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def load
raise e
end
begin
Object.const_get(cask_class_name).new
Object.const_get(cask_class_name).new(path)
rescue CaskError, StandardError, ScriptError => e
# bug: e.message.concat doesn't work with CaskError exceptions
e.message.concat(" while instantiating '#{cask_class_name}' from '#{path}'")
Expand Down
5 changes: 5 additions & 0 deletions lib/cask/without_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ def staged_path
caskroom_path.children.first
end

def initialize(sourcefile_path=nil)
@sourcefile_path = sourcefile_path
@token = sourcefile_path
end

def to_s
"#{token} (!)"
end
Expand Down