Skip to content

Commit

Permalink
Merge pull request #3066 from rolandwalker/snapshot_caskfiles
Browse files Browse the repository at this point in the history
Store metadata with installed Casks.
  • Loading branch information
rolandwalker committed Dec 11, 2014
2 parents 0ff7027 + bf99c6b commit 6bed7f5
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
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

0 comments on commit 6bed7f5

Please sign in to comment.