diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-17 19:05:49 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-17 19:05:49 +0300 |
commit | 43a25d93ebdabea52f99b05e15b06250cd8f07d7 (patch) | |
tree | dceebdc68925362117480a5d672bcff122fb625b /lib/safe_zip | |
parent | 20c84b99005abd1c82101dfeff264ac50d2df211 (diff) |
Add latest changes from gitlab-org/gitlab@16-0-stable-eev16.0.0-rc42
Diffstat (limited to 'lib/safe_zip')
-rw-r--r-- | lib/safe_zip/extract.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/safe_zip/extract.rb b/lib/safe_zip/extract.rb index b86941e6bea..3403e3e429e 100644 --- a/lib/safe_zip/extract.rb +++ b/lib/safe_zip/extract.rb @@ -1,6 +1,13 @@ # frozen_string_literal: true module SafeZip + # SafeZip::Extract provides a safe interface + # to extract specific directories or files within a `zip` archive. + # + # @example Extract directories to destination + # SafeZip::Extract.new(archive_file).extract(directories: ['app/', 'test/'], to: destination_path) + # @example Extract files to destination + # SafeZip::Extract.new(archive_file).extract(files: ['index.html', 'app/index.js'], to: destination_path) class Extract Error = Class.new(StandardError) PermissionDeniedError = Class.new(Error) @@ -17,6 +24,20 @@ module SafeZip @archive_path = archive_file end + # extract given files or directories from the archive into the destination path + # + # @param [Hash] opts the options for extraction. + # @option opts [Array<String] :files list of files to be extracted + # @option opts [Array<String] :directories list of directories to be extracted + # @option opts [String] :to destination path + # + # @raise [PermissionDeniedError] + # @raise [SymlinkSourceDoesNotExistError] + # @raise [UnsupportedEntryError] + # @raise [EntrySizeError] + # @raise [AlreadyExistsError] + # @raise [NoMatchingError] + # @raise [ExtractError] def extract(opts = {}) params = SafeZip::ExtractParams.new(**opts) |