Skip to content

Commit 5e1edd5

Browse files
committed
Seriously, don't create sandboxes in detect and release
An earlier attempt to prevent sandboxes from being created in detect and release wasn't entirely successful. This change finishes the job and ensures that, seriously, sandboxes aren't created when they shouldn't be. [#62947962]
1 parent 9b2925a commit 5e1edd5

4 files changed

Lines changed: 6 additions & 23 deletions

File tree

lib/java_buildpack/component/base_component.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def download_zip(version, uri, strip_top_level = true, target_directory = @dropl
132132
Dir.mktmpdir do |root|
133133
shell "unzip -qq #{file.path} -d #{root} 2>&1"
134134

135-
FileUtils.rm_r target_directory
135+
FileUtils.mkdir_p target_directory.parent
136136
FileUtils.mv Pathname.new(root).children.first, target_directory
137137
end
138138
else

lib/java_buildpack/component/droplet.rb

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ class Droplet
5353
# excludes files in the sandboxes of other components
5454
attr_reader :root
5555

56+
# @!attribute [r] sandbox
57+
# @return [Pathname] the root of the component's sandbox
58+
attr_reader :sandbox
59+
5660
# Creates a new instance of the droplet abstraction
5761
#
5862
# @param [AdditionalLibraries] additional_libraries the shared +AdditionalLibraries+ instance for all components
@@ -94,14 +98,6 @@ def copy_resources(target_directory = @sandbox)
9498
end
9599
end
96100

97-
# Returns the root of the component's sandbox
98-
#
99-
# @return [Pathname] the root of the component's sandbox
100-
def sandbox
101-
FileUtils.mkdir_p @sandbox unless @sandbox.exist?
102-
@sandbox
103-
end
104-
105101
private
106102

107103
RESOURCES_DIRECTORY = Pathname.new(File.expand_path('../../../../resources', __FILE__))

lib/java_buildpack/container/tomcat.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ def download_support
112112

113113
def expand(file)
114114
with_timing "Expanding Tomcat to #{@droplet.sandbox.relative_path_from(@droplet.root)}" do
115+
FileUtils.mkdir_p @droplet.sandbox
115116
shell "tar xzf #{file.path} -C #{@droplet.sandbox} --strip 1 --exclude webapps 2>&1"
116117

117118
@droplet.copy_resources

spec/java_buildpack/component/droplet_spec.rb

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,4 @@
8282
droplet.copy_resources
8383
end
8484

85-
it 'should not initialize sandbox until it is used' do
86-
sandbox_dir = app_dir + '.java-buildpack/droplet'
87-
88-
expect(sandbox_dir).not_to exist
89-
90-
droplet
91-
92-
expect(sandbox_dir).not_to exist
93-
94-
droplet.sandbox
95-
96-
expect(sandbox_dir).to exist
97-
end
98-
9985
end

0 commit comments

Comments
 (0)