litestream 0.6.0-x86_64-darwin → 0.7.0-x86_64-darwin
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/litestream/commands.rb +19 -18
- data/lib/litestream/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75f39eb6b172e110a094a82699b67806eb4305fbc1701547cab58a27c83e4ea3
|
4
|
+
data.tar.gz: 7cb76b03b3224081ead9a508a504f2ec8fc2fcc107b54a4e7b15627bdde7bf28
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c6852efcd97ba1216a0c2da06d2d74dcd9da3af0fa24a3f050aa8191aa50759d17694dc740da58758a80f49701d89977100a5096d1ada9499c7b33e187eaf93
|
7
|
+
data.tar.gz: 21eabb4cf37cbfb18991c0b15df85cf004a803539a62357e689d0f466ec152e5ff8dfe0a247aab4b8b80883c9a07a2a5d9530cf9c28a61ca8289f1b0be5e8bb0
|
data/lib/litestream/commands.rb
CHANGED
@@ -17,8 +17,8 @@ module Litestream
|
|
17
17
|
# raised when a litestream command requires a database argument but it isn't provided
|
18
18
|
DatabaseRequiredException = Class.new(StandardError)
|
19
19
|
|
20
|
-
# raised when litestream fails
|
21
|
-
|
20
|
+
# raised when a litestream command fails
|
21
|
+
CommandFailedException = Class.new(StandardError)
|
22
22
|
|
23
23
|
class << self
|
24
24
|
def platform
|
@@ -77,16 +77,14 @@ module Litestream
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def replicate(async: false, **argv)
|
80
|
-
execute("replicate", argv, async: async,
|
80
|
+
execute("replicate", argv, async: async, tabled_output: false)
|
81
81
|
end
|
82
82
|
|
83
83
|
def restore(database, async: false, **argv)
|
84
84
|
raise DatabaseRequiredException, "database argument is required for restore command, e.g. litestream:restore -- --database=path/to/database.sqlite" if database.nil?
|
85
85
|
argv.stringify_keys!
|
86
86
|
|
87
|
-
execute("restore", argv, database, async: async,
|
88
|
-
|
89
|
-
argv["-o"] || database
|
87
|
+
execute("restore", argv, database, async: async, tabled_output: false)
|
90
88
|
end
|
91
89
|
|
92
90
|
def verify(database, async: false, **argv)
|
@@ -101,10 +99,7 @@ module Litestream
|
|
101
99
|
args = {
|
102
100
|
"-o" => backup
|
103
101
|
}.merge(argv)
|
104
|
-
|
105
|
-
backup = restore(database, async: false, **args)
|
106
|
-
|
107
|
-
raise BackupFailedException, "Failed to create backup for validation" unless File.exist?(backup)
|
102
|
+
restore(database, async: false, **args)
|
108
103
|
|
109
104
|
restored_tables_count = `sqlite3 #{backup} "select count(*) from sqlite_schema where type='table';"`.chomp.to_i
|
110
105
|
restored_size = File.size(backup)
|
@@ -120,26 +115,32 @@ module Litestream
|
|
120
115
|
end
|
121
116
|
|
122
117
|
def databases(async: false, **argv)
|
123
|
-
execute("databases", argv, async: async,
|
118
|
+
execute("databases", argv, async: async, tabled_output: true)
|
124
119
|
end
|
125
120
|
|
126
121
|
def generations(database, async: false, **argv)
|
127
122
|
raise DatabaseRequiredException, "database argument is required for generations command, e.g. litestream:generations -- --database=path/to/database.sqlite" if database.nil?
|
128
123
|
|
129
|
-
execute("generations", argv, database, async: async,
|
124
|
+
execute("generations", argv, database, async: async, tabled_output: true)
|
130
125
|
end
|
131
126
|
|
132
127
|
def snapshots(database, async: false, **argv)
|
133
128
|
raise DatabaseRequiredException, "database argument is required for snapshots command, e.g. litestream:snapshots -- --database=path/to/database.sqlite" if database.nil?
|
134
129
|
|
135
|
-
execute("snapshots", argv, database, async: async,
|
130
|
+
execute("snapshots", argv, database, async: async, tabled_output: true)
|
136
131
|
end
|
137
132
|
|
138
133
|
private
|
139
134
|
|
140
|
-
def execute(command, argv = {}, database = nil, async: false,
|
135
|
+
def execute(command, argv = {}, database = nil, async: false, tabled_output: false)
|
141
136
|
cmd = prepare(command, argv, database)
|
142
|
-
run(cmd, async: async,
|
137
|
+
results = run(cmd, async: async, tabled_output: tabled_output)
|
138
|
+
|
139
|
+
if Array === results && results.one? && results[0]["level"] == "ERROR"
|
140
|
+
raise CommandFailedException, "Failed to execute `#{cmd.join(" ")}`; Reason: #{results[0]["error"]}"
|
141
|
+
else
|
142
|
+
results
|
143
|
+
end
|
143
144
|
end
|
144
145
|
|
145
146
|
def prepare(command, argv = {}, database = nil)
|
@@ -158,14 +159,14 @@ module Litestream
|
|
158
159
|
cmd
|
159
160
|
end
|
160
161
|
|
161
|
-
def run(cmd, async: false,
|
162
|
+
def run(cmd, async: false, tabled_output: false)
|
162
163
|
if async
|
163
164
|
# To release the resources of the Ruby process, just fork and exit.
|
164
165
|
# The forked process executes litestream and replaces itself.
|
165
166
|
exec(*cmd) if fork.nil?
|
166
167
|
else
|
167
|
-
|
168
|
-
text_table_to_hashes(
|
168
|
+
stdout = `#{cmd.join(" ")}`.champ
|
169
|
+
tabled_output ? text_table_to_hashes(stdout) : stdout.split("\n").map { Logfmt.parse(_1) }
|
169
170
|
end
|
170
171
|
end
|
171
172
|
|
data/lib/litestream/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: litestream
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: x86_64-darwin
|
6
6
|
authors:
|
7
7
|
- Stephen Margheim
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: logfmt
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.0.10
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.0.10
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rubyzip
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|