aptly-api 0.8.2 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +14 -0
- data/lib/aptly/files.rb +52 -0
- data/lib/aptly/repository.rb +3 -6
- data/lib/aptly/tmpname.rb +2 -1
- data/lib/aptly/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2f05bd8ea6f8823c9ecbdd75ece3fd75fea137e1c7feaf3ee9be7bacbc746fa6
|
4
|
+
data.tar.gz: 80e7d9229aa43d4d39a2d563a3570623a9beae956fc9add43ea53cb6dd985a02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea9a99200d5c2a5c76c60013b2a90c695674bc31c9d63ea1cb5fd13912edcf5aa0696b79a9fe84289b93ddb46a170859108ba5e8b8c7fc1190ef99bb612b1126
|
7
|
+
data.tar.gz: 5f9731ea0d96ea4dbd0723598500f9e6ce6707ef30fd675e3cc1aad65542d7e8747fdb9b0b78361c35a636b52ecc4079351857595177f80c19911f1a68a4f32f
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## [0.9.0]
|
4
|
+
### Added
|
5
|
+
- `Files.tmp_upload` is a new convenience wrapper around `#upload` and
|
6
|
+
`#delete`. It picks a temporary directory name and uploads the list of files
|
7
|
+
to that directory, it then yields the directory name so you can use it as file
|
8
|
+
identifier for the files. When the method returns it automatically cleans the
|
9
|
+
remote up via `#delete`.
|
10
|
+
|
11
|
+
### Changed
|
12
|
+
- `Repository.upload` is now based on `Files.tmp_upload`. Functionally
|
13
|
+
all remains the same; the temporary directory name on the remote changes.
|
14
|
+
- Temporary directory names now include a thread id to reduce the risk of
|
15
|
+
conflicts across different threads.
|
16
|
+
|
3
17
|
## [0.8.2]
|
4
18
|
### Fixed
|
5
19
|
- Temporary files no longer contain characters that trip up the daemon.
|
data/lib/aptly/files.rb
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
# Copyright (C) 2015-2018 Harald Sitter <sitter@kde.org>
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 3 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
15
|
+
|
1
16
|
module Aptly
|
2
17
|
# Aptly files management.
|
3
18
|
# @see http://www.aptly.info/doc/api/files/
|
@@ -14,6 +29,36 @@ module Aptly
|
|
14
29
|
JSON.parse(response.body)
|
15
30
|
end
|
16
31
|
|
32
|
+
# Upload files into a temporary directory on remote.
|
33
|
+
# This method expects a block which will be yielded to with the directory
|
34
|
+
# name on the remote. The directory will be deleted when this method
|
35
|
+
# returns.
|
36
|
+
# You'll generally want to use this instead of #upload so you don't have
|
37
|
+
# to worry about name collission and clean up.
|
38
|
+
#
|
39
|
+
# @param files [Array<String>] paths to files to upload
|
40
|
+
# @param connection [Connection] connection to use
|
41
|
+
# @yield [String] the remote directory name the files were uploaded to
|
42
|
+
# @return return value of block
|
43
|
+
#
|
44
|
+
# @example Can be used to push into multiple repositories with one upload
|
45
|
+
# Files.tmp_upload(files) { |d| repos.each { |r| r.add_files(d) } }
|
46
|
+
#
|
47
|
+
# @since 0.9.0
|
48
|
+
def tmp_upload(files, connection = Connection.new, **kwords)
|
49
|
+
# TODO: 1.0 find out if #upload even has a use case and maybe replace it
|
50
|
+
dir = tmp_dir_name
|
51
|
+
upload(files, dir, connection, **kwords)
|
52
|
+
uploaded = true
|
53
|
+
yield dir
|
54
|
+
ensure
|
55
|
+
# We have an uploaded var here as exceptions raised by upload would
|
56
|
+
# still run this, but they may not have the remote file, so our
|
57
|
+
# delete request would again cause an error making it harder to spot
|
58
|
+
# the orignal problem.
|
59
|
+
delete(dir) if uploaded
|
60
|
+
end
|
61
|
+
|
17
62
|
# Delete files from remote's upload directory.
|
18
63
|
# @param path [String] path to delete (this may be a directory or a file)
|
19
64
|
# @return [nil]
|
@@ -21,6 +66,13 @@ module Aptly
|
|
21
66
|
connection.send(:delete, "/files/#{path}", kwords)
|
22
67
|
nil
|
23
68
|
end
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
def tmp_dir_name
|
73
|
+
prefix = "#{to_s.tr(':', '_')}-#{Socket.gethostname}"
|
74
|
+
TmpName.dir(prefix)
|
75
|
+
end
|
24
76
|
end
|
25
77
|
end
|
26
78
|
end
|
data/lib/aptly/repository.rb
CHANGED
@@ -52,12 +52,9 @@ module Aptly
|
|
52
52
|
# FIXME: needs to support single files
|
53
53
|
# Convenience wrapper around {Files.upload}, {#add_file} and {Files.delete}
|
54
54
|
def upload(files)
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
add_file(directory)
|
59
|
-
ensure
|
60
|
-
Files.delete(directory, connection)
|
55
|
+
Files.tmp_upload(files, connection) do |dir|
|
56
|
+
add_file(dir)
|
57
|
+
end
|
61
58
|
end
|
62
59
|
|
63
60
|
# List all packages in the repository
|
data/lib/aptly/tmpname.rb
CHANGED
@@ -20,12 +20,13 @@ module Aptly
|
|
20
20
|
module TmpName
|
21
21
|
# @return [String] temporary directory name (only safe characters)
|
22
22
|
def self.dir(prefix)
|
23
|
-
format('%<prefix>s-%<time>s-%<pid>s-%<rand>s',
|
23
|
+
format('%<prefix>s-%<time>s-%<pid>s-%<tid>s-%<rand>s',
|
24
24
|
prefix: prefix,
|
25
25
|
# rubocop:disable Style/FormatStringToken
|
26
26
|
time: Time.now.strftime('%Y%m%d'),
|
27
27
|
# rubocop:enable Style/FormatStringToken
|
28
28
|
pid: $PROCESS_ID,
|
29
|
+
tid: Thread.current.object_id,
|
29
30
|
rand: rand(0x100000000).to_s(36))
|
30
31
|
end
|
31
32
|
end
|
data/lib/aptly/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aptly-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Harald Sitter
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-02-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -202,7 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
202
202
|
version: '0'
|
203
203
|
requirements: []
|
204
204
|
rubyforge_project:
|
205
|
-
rubygems_version: 2.
|
205
|
+
rubygems_version: 2.7.3
|
206
206
|
signing_key:
|
207
207
|
specification_version: 4
|
208
208
|
summary: REST client for the Aptly API
|