Sha256: 4737fa00fc3ec0ca3cdc2f872df309991e7af9d24f0832994f2328f7f12c7015

Contents?: true

Size: 1.27 KB

Versions: 3

Compression:

Stored size: 1.27 KB

Contents

# Copyright 2014 Red Hat, Inc, and individual contributors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'fileutils'

at_exit do
  # Clean up any temporary files left around by our jar unpacking
  # shenanigans. This is only used when executing a script inside
  # an archive, which ends up calling Kernel.exec and bypassing the
  # typical temp file cleaning mechanisms.
  java_tmpdir = File.expand_path(java.lang.System.get_property('java.io.tmpdir'))
  app_jar = java.lang.System.get_property('torquebox.app_jar')
  paths = $LOAD_PATH + [app_jar]
  path_pattern = %r{^(#{java_tmpdir}/wunderboss.+?/).+}
  paths.each do |path|
    path = File.expand_path(path)
    if path =~ path_pattern
      dir = $1
      if Dir.exist?(dir)
        FileUtils.rm_rf(dir)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
torquebox-core-4.0.0.beta3-java lib/torquebox/cli/archive_cleaner.rb
torquebox-core-4.0.0.beta2-java lib/torquebox/cli/archive_cleaner.rb
torquebox-core-4.0.0.beta1-java lib/torquebox/cli/archive_cleaner.rb