file-digests 0.0.41 → 0.0.42

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/file-digests +0 -0
  3. data/lib/file-digests.rb +18 -10
  4. metadata +6 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 911caad1e008b6365ad3f0043e992793a9d77ff13ce71b0da004608a8261398b
4
- data.tar.gz: f98a696b52e1549694d6ff80f9b3efe894b8ad9dc79c7bc7da1a01a74800fb77
3
+ metadata.gz: c914ef250d4e173e31498c81865f4b43da56f91f81f2f16325f573747758c20b
4
+ data.tar.gz: 55bec69638ec367ca346de5b1d72194daa0bab75972186e0dd3ca4da0a0ceb9e
5
5
  SHA512:
6
- metadata.gz: 9004f1053569a94f58a4f90279ae1c86597a72baa0451ea62bf0481650f3e049d5a4dff6c513e093abf808cf603ec6e9d4ad017a143c16d8ed16007912797b6c
7
- data.tar.gz: fa65d38a9fe7dde9cc29f5a389d6f1ee52e4593637b0f67a2173821180f8aeeea9bddddf6bbf95ecc7a9ada47364869f4ef087e90b405ef1d7329d00f9c39375
6
+ metadata.gz: 3963d53565a261db7b7bad2d8d662aa8fe407b92ddca9264afd10f6f9451f6aa1cfeec2825a503fc6b01f18cc85a672e4cf031109a2279e3c2d74d5c74c7cdb2
7
+ data.tar.gz: e6be01d8d1887010387ba5206bcb5937dac395fa5ea05c546076f76998d4603030ba5e781f43c2414e99f20bc241fcc3446721e7b9dca668af0fe7e6cff7fe46
data/bin/file-digests CHANGED
File without changes
data/lib/file-digests.rb CHANGED
@@ -113,6 +113,7 @@ class FileDigests
113
113
 
114
114
  file_digests = self.new ARGV[0], ARGV[1], options
115
115
  file_digests.send(options[:action] || :perform_check)
116
+ file_digests.close_database
116
117
  end
117
118
 
118
119
  def initialize files_path, digest_database_path, options = {}
@@ -187,13 +188,11 @@ class FileDigests
187
188
 
188
189
  print_counters
189
190
  end
190
-
191
+
191
192
  puts "Performing database maintenance..." if @options[:verbose]
192
193
  execute "PRAGMA optimize"
193
194
  execute "VACUUM"
194
195
  execute "PRAGMA wal_checkpoint(TRUNCATE)"
195
-
196
- hide_database_files
197
196
  end
198
197
  end
199
198
 
@@ -209,17 +208,23 @@ class FileDigests
209
208
  end
210
209
  end
211
210
 
211
+ def close_database
212
+ @statements.each(&:close)
213
+ @db.close
214
+ hide_database_files
215
+ end
216
+
212
217
  private
213
218
 
214
219
  def initialize_paths files_path, digest_database_path
215
220
  @files_path = realpath(files_path || ".")
216
-
221
+
217
222
  unless File.directory?(@files_path) && File.readable?(@files_path)
218
- raise "ERROR: Files path must be a readable directory"
223
+ raise "ERROR: Files path must be a readable directory"
219
224
  end
220
225
 
221
226
  @start_time_filename_string = Time.now.strftime("%Y-%m-%d %H-%M-%S")
222
-
227
+
223
228
  @error_log_path = "#{@files_path}#{File::SEPARATOR}file-digests errors #{@start_time_filename_string}.txt"
224
229
  @missing_files_path = "#{@files_path}#{File::SEPARATOR}file-digests missing files #{@start_time_filename_string}.txt"
225
230
 
@@ -250,6 +255,7 @@ class FileDigests
250
255
  @db = SQLite3::Database.new @digest_database_path
251
256
  @db.results_as_hash = true
252
257
  @db.busy_timeout = 5000
258
+ @statements = []
253
259
 
254
260
  execute "PRAGMA encoding = 'UTF-8'"
255
261
  execute "PRAGMA locking_mode = 'EXCLUSIVE'"
@@ -319,7 +325,7 @@ class FileDigests
319
325
  execute "CREATE INDEX digests_digest ON digests(digest)"
320
326
  set_metadata "database_version", "3"
321
327
  end
322
-
328
+
323
329
  check_if_database_is_at_certain_version "3"
324
330
 
325
331
  create_temporary_tables
@@ -359,7 +365,6 @@ class FileDigests
359
365
  prepare_method :digests_update_digests_to_new_digests, "INSERT INTO digests (filename, digest, digest_check_time) SELECT filename, digest, false FROM new_digests WHERE true ON CONFLICT (filename) DO UPDATE SET digest=excluded.digest"
360
366
  end
361
367
 
362
-
363
368
  # Files
364
369
 
365
370
  def realpath path
@@ -413,7 +418,7 @@ class FileDigests
413
418
  item = "#{path}#{File::SEPARATOR}#{item.encode("utf-8")}"
414
419
  begin
415
420
  item_perhaps_nt_path = perhaps_nt_path item
416
-
421
+
417
422
  unless File.symlink? item_perhaps_nt_path
418
423
  if File.directory?(item_perhaps_nt_path)
419
424
  raise "Directory is not readable" unless File.readable?(item_perhaps_nt_path)
@@ -596,7 +601,10 @@ class FileDigests
596
601
  def prepare_method name, query
597
602
  variable = "@#{name}"
598
603
 
599
- instance_variable_set(variable, @db.prepare(query))
604
+ statement = @db.prepare(query)
605
+ @statements.push(statement)
606
+
607
+ instance_variable_set(variable, statement)
600
608
 
601
609
  define_singleton_method name do |*args, &block|
602
610
  instance_variable_get(variable).execute(*args, &block)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: file-digests
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.41
4
+ version: 0.0.42
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stanislav Senotrusov
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-20 00:00:00.000000000 Z
11
+ date: 2021-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: openssl
@@ -51,7 +51,7 @@ homepage: https://github.com/senotrusov/file-digests
51
51
  licenses:
52
52
  - Apache-2.0
53
53
  metadata: {}
54
- post_install_message:
54
+ post_install_message:
55
55
  rdoc_options: []
56
56
  require_paths:
57
57
  - lib
@@ -66,8 +66,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
66
  - !ruby/object:Gem::Version
67
67
  version: '0'
68
68
  requirements: []
69
- rubygems_version: 3.1.2
70
- signing_key:
69
+ rubygems_version: 3.1.4
70
+ signing_key:
71
71
  specification_version: 4
72
72
  summary: file-digests
73
73
  test_files: []