litestream 0.5.5-arm64-darwin → 0.7.0-arm64-darwin
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/lib/litestream/commands.rb +26 -24
 - data/lib/litestream/upstream.rb +0 -1
 - data/lib/litestream/version.rb +1 -1
 - data/lib/tasks/litestream_tasks.rake +6 -6
 - 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: 967c31a26666bcd7193ede513157881e3fc1f66d2ea0a6efaf7b447d38b58f4f
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 43bc78c25f357d6c0ee553a5f5f883b019e9ad7e7fbfb7f5ce094a1e50572ab4
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 1db86a3b28f14a1c0a5151fd69875dcdbbb93ef65a4709e113105775754864f2a4f6d5c64c5eddfdef55bfa01fecbb307ecec4d3cc59f2ccab563ef8d403d2c5
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: b2fb5ca27c1c9f4348baba9322d638544dc323fe55243d289a1397b00916ecfab6a424205d60a99b862dbc8745b90c0871205e9879dc9c7d225a5392b09d688e
         
     | 
    
        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,33 +77,29 @@ 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 
     | 
    
         
            +
                    argv.stringify_keys!
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
                    execute("restore", argv, database, async: async, tabled_output: false)
         
     | 
| 
      
 88 
     | 
    
         
            +
                  end
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
                  def verify(database, async: false, **argv)
         
     | 
| 
      
 91 
     | 
    
         
            +
                    raise DatabaseRequiredException, "database argument is required for verify command, e.g. litestream:verify -- --database=path/to/database.sqlite" if database.nil? || !File.exist?(database)
         
     | 
| 
      
 92 
     | 
    
         
            +
                    argv.stringify_keys!
         
     | 
| 
       85 
93 
     | 
    
         | 
| 
       86 
94 
     | 
    
         
             
                    dir, file = File.split(database)
         
     | 
| 
       87 
95 
     | 
    
         
             
                    ext = File.extname(file)
         
     | 
| 
       88 
96 
     | 
    
         
             
                    base = File.basename(file, ext)
         
     | 
| 
       89 
97 
     | 
    
         
             
                    now = Time.now.utc.strftime("%Y%m%d%H%M%S")
         
     | 
| 
       90 
98 
     | 
    
         
             
                    backup = File.join(dir, "#{base}-#{now}#{ext}")
         
     | 
| 
       91 
     | 
    
         
            -
             
     | 
| 
       92 
99 
     | 
    
         
             
                    args = {
         
     | 
| 
       93 
100 
     | 
    
         
             
                      "-o" => backup
         
     | 
| 
       94 
101 
     | 
    
         
             
                    }.merge(argv)
         
     | 
| 
       95 
     | 
    
         
            -
             
     | 
| 
       96 
     | 
    
         
            -
                    execute("restore", args, database, async: async, hashify: false)
         
     | 
| 
       97 
     | 
    
         
            -
             
     | 
| 
       98 
     | 
    
         
            -
                    backup
         
     | 
| 
       99 
     | 
    
         
            -
                  end
         
     | 
| 
       100 
     | 
    
         
            -
             
     | 
| 
       101 
     | 
    
         
            -
                  def verify(database, async: false, **argv)
         
     | 
| 
       102 
     | 
    
         
            -
                    raise DatabaseRequiredException, "database argument is required for verify command, e.g. litestream:verify -- --database=path/to/database.sqlite" if database.nil? || !File.exist?(database)
         
     | 
| 
       103 
     | 
    
         
            -
             
     | 
| 
       104 
     | 
    
         
            -
                    backup = restore(database, async: false, **argv)
         
     | 
| 
       105 
     | 
    
         
            -
             
     | 
| 
       106 
     | 
    
         
            -
                    raise BackupFailedException, "Failed to create backup for validation" unless File.exist?(backup)
         
     | 
| 
      
 102 
     | 
    
         
            +
                    restore(database, async: false, **args)
         
     | 
| 
       107 
103 
     | 
    
         | 
| 
       108 
104 
     | 
    
         
             
                    restored_tables_count = `sqlite3 #{backup} "select count(*) from sqlite_schema where type='table';"`.chomp.to_i
         
     | 
| 
       109 
105 
     | 
    
         
             
                    restored_size = File.size(backup)
         
     | 
| 
         @@ -119,26 +115,32 @@ module Litestream 
     | 
|
| 
       119 
115 
     | 
    
         
             
                  end
         
     | 
| 
       120 
116 
     | 
    
         | 
| 
       121 
117 
     | 
    
         
             
                  def databases(async: false, **argv)
         
     | 
| 
       122 
     | 
    
         
            -
                    execute("databases", argv, async: async,  
     | 
| 
      
 118 
     | 
    
         
            +
                    execute("databases", argv, async: async, tabled_output: true)
         
     | 
| 
       123 
119 
     | 
    
         
             
                  end
         
     | 
| 
       124 
120 
     | 
    
         | 
| 
       125 
121 
     | 
    
         
             
                  def generations(database, async: false, **argv)
         
     | 
| 
       126 
122 
     | 
    
         
             
                    raise DatabaseRequiredException, "database argument is required for generations command, e.g. litestream:generations -- --database=path/to/database.sqlite" if database.nil?
         
     | 
| 
       127 
123 
     | 
    
         | 
| 
       128 
     | 
    
         
            -
                    execute("generations", argv, database, async: async,  
     | 
| 
      
 124 
     | 
    
         
            +
                    execute("generations", argv, database, async: async, tabled_output: true)
         
     | 
| 
       129 
125 
     | 
    
         
             
                  end
         
     | 
| 
       130 
126 
     | 
    
         | 
| 
       131 
127 
     | 
    
         
             
                  def snapshots(database, async: false, **argv)
         
     | 
| 
       132 
128 
     | 
    
         
             
                    raise DatabaseRequiredException, "database argument is required for snapshots command, e.g. litestream:snapshots -- --database=path/to/database.sqlite" if database.nil?
         
     | 
| 
       133 
129 
     | 
    
         | 
| 
       134 
     | 
    
         
            -
                    execute("snapshots", argv, database, async: async,  
     | 
| 
      
 130 
     | 
    
         
            +
                    execute("snapshots", argv, database, async: async, tabled_output: true)
         
     | 
| 
       135 
131 
     | 
    
         
             
                  end
         
     | 
| 
       136 
132 
     | 
    
         | 
| 
       137 
133 
     | 
    
         
             
                  private
         
     | 
| 
       138 
134 
     | 
    
         | 
| 
       139 
     | 
    
         
            -
                  def execute(command, argv = {}, database = nil, async: false,  
     | 
| 
      
 135 
     | 
    
         
            +
                  def execute(command, argv = {}, database = nil, async: false, tabled_output: false)
         
     | 
| 
       140 
136 
     | 
    
         
             
                    cmd = prepare(command, argv, database)
         
     | 
| 
       141 
     | 
    
         
            -
                    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
         
     | 
| 
       142 
144 
     | 
    
         
             
                  end
         
     | 
| 
       143 
145 
     | 
    
         | 
| 
       144 
146 
     | 
    
         
             
                  def prepare(command, argv = {}, database = nil)
         
     | 
| 
         @@ -157,14 +159,14 @@ module Litestream 
     | 
|
| 
       157 
159 
     | 
    
         
             
                    cmd
         
     | 
| 
       158 
160 
     | 
    
         
             
                  end
         
     | 
| 
       159 
161 
     | 
    
         | 
| 
       160 
     | 
    
         
            -
                  def run(cmd, async: false,  
     | 
| 
      
 162 
     | 
    
         
            +
                  def run(cmd, async: false, tabled_output: false)
         
     | 
| 
       161 
163 
     | 
    
         
             
                    if async
         
     | 
| 
       162 
164 
     | 
    
         
             
                      # To release the resources of the Ruby process, just fork and exit.
         
     | 
| 
       163 
165 
     | 
    
         
             
                      # The forked process executes litestream and replaces itself.
         
     | 
| 
       164 
166 
     | 
    
         
             
                      exec(*cmd) if fork.nil?
         
     | 
| 
       165 
167 
     | 
    
         
             
                    else
         
     | 
| 
       166 
     | 
    
         
            -
                       
     | 
| 
       167 
     | 
    
         
            -
                      text_table_to_hashes( 
     | 
| 
      
 168 
     | 
    
         
            +
                      stdout = `#{cmd.join(" ")}`.champ
         
     | 
| 
      
 169 
     | 
    
         
            +
                      tabled_output ? text_table_to_hashes(stdout) : stdout.split("\n").map { Logfmt.parse(_1) }
         
     | 
| 
       168 
170 
     | 
    
         
             
                    end
         
     | 
| 
       169 
171 
     | 
    
         
             
                  end
         
     | 
| 
       170 
172 
     | 
    
         | 
    
        data/lib/litestream/upstream.rb
    CHANGED
    
    
    
        data/lib/litestream/version.rb
    CHANGED
    
    
| 
         @@ -97,14 +97,14 @@ namespace :litestream do 
     | 
|
| 
       97 
97 
     | 
    
         
             
                puts <<~TXT if result
         
     | 
| 
       98 
98 
     | 
    
         | 
| 
       99 
99 
     | 
    
         
             
                  size
         
     | 
| 
       100 
     | 
    
         
            -
                    original          #{result[ 
     | 
| 
       101 
     | 
    
         
            -
                    restored          #{result[ 
     | 
| 
       102 
     | 
    
         
            -
                    delta             #{result[ 
     | 
| 
      
 100 
     | 
    
         
            +
                    original          #{result["size"]["original"]}
         
     | 
| 
      
 101 
     | 
    
         
            +
                    restored          #{result["size"]["restored"]}
         
     | 
| 
      
 102 
     | 
    
         
            +
                    delta             #{result["size"]["original"] - result["size"]["restored"]}
         
     | 
| 
       103 
103 
     | 
    
         | 
| 
       104 
104 
     | 
    
         
             
                  tables
         
     | 
| 
       105 
     | 
    
         
            -
                    original          #{result[ 
     | 
| 
       106 
     | 
    
         
            -
                    restored          #{result[ 
     | 
| 
       107 
     | 
    
         
            -
                    delta             #{result[ 
     | 
| 
      
 105 
     | 
    
         
            +
                    original          #{result["tables"]["original"]}
         
     | 
| 
      
 106 
     | 
    
         
            +
                    restored          #{result["tables"]["restored"]}
         
     | 
| 
      
 107 
     | 
    
         
            +
                    delta             #{result["tables"]["original"] - result["tables"]["restored"]}
         
     | 
| 
       108 
108 
     | 
    
         
             
                TXT
         
     | 
| 
       109 
109 
     | 
    
         
             
              end
         
     | 
| 
       110 
110 
     | 
    
         
             
            end
         
     | 
    
        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: arm64-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
         
     |