file-digests 0.0.3 → 0.0.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4b996011c4d3ae950a0081174ea86d0fe52136f58fd09c3e4543bfbdf3240098
4
- data.tar.gz: 5055ba39b9d1e2cccd1cb89603e088ecf8052cb48bc36443be7b520ffc585e83
3
+ metadata.gz: 77a80b8a8ca297b757b13f991c2890c928a9fe9824319595489f273c2c13d212
4
+ data.tar.gz: 9136567171037d0c0426d714d2999e3232335e26b9782bb1c1db9144cfe7ca8a
5
5
  SHA512:
6
- metadata.gz: e4325a69e293cdf3b3007bbc100f163bf26ef0ed06da33e0fb58476fd59b2d8c57a6ee9984acd57eaab778b38e334d9d78cd2fa71bd5a63971804b060b0fa167
7
- data.tar.gz: 02263b3b793bcdd3caf8cccd9b07a5232b001bd25d45709ead019be0a002ed5f6eb94ebbed3f3719bc5b7fceeb8b32a918e8ed59f15fdf345c78d0437eab7999
6
+ metadata.gz: ff53170d154b2cb03fb05c9681a43a1a596a4a807036344b9724ccff2a8e29551efb13e4e3130fbb7e7cbd931409f44a4ccb3a00279081796e7e1e9c6202882f
7
+ data.tar.gz: 7f598540535e96c8f6bb26360e854a83e93f3d1c9d219de1eec440150cedd74cf8e6f4b8af5b065f1262fedd3602bf187f056e3f378772a4c15c16132aea79b6
@@ -21,7 +21,7 @@ def measure_time
21
21
  start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
22
22
  yield
23
23
  elapsed = (Process.clock_gettime(Process::CLOCK_MONOTONIC) - start).to_i
24
- puts "Elapsed time: #{elapsed / 3600}h #{(elapsed % 3600) / 60}m #{elapsed % 60}s" if VERBOSE
24
+ puts "Elapsed time: #{elapsed / 3600}h #{(elapsed % 3600) / 60}m #{elapsed % 60}s" unless QUIET
25
25
  end
26
26
 
27
27
  def patch_path_string path
@@ -43,6 +43,11 @@ class DigestDatabase
43
43
  @db.execute "CREATE UNIQUE INDEX digests_filename ON digests(filename)"
44
44
  end
45
45
 
46
+ @db.execute 'PRAGMA journal_mode = "WAL"'
47
+ @db.execute 'PRAGMA synchronous = "NORMAL"'
48
+ @db.execute 'PRAGMA locking_mode = "EXCLUSIVE"'
49
+ @db.execute 'PRAGMA cache_size = "5000"'
50
+
46
51
  @db.results_as_hash = true
47
52
  @missing_files = Hash[@db.prepare("SELECT filename, digest FROM digests").execute!]
48
53
  @new_files = {}
@@ -66,7 +71,7 @@ class DigestDatabase
66
71
 
67
72
  if found['digest'] == digest
68
73
  COUNTS[:good] += 1
69
- puts "GOOD: #{file_path}" if VERBOSE
74
+ # puts "GOOD: #{file_path}" unless QUIET
70
75
  unless TEST_ONLY
71
76
  if found['mtime'] == mtime
72
77
  @touch_digest_check_time.execute found['id']
@@ -77,10 +82,10 @@ class DigestDatabase
77
82
  else
78
83
  if found['mtime'] == mtime # Digest is different and mtime is the same
79
84
  COUNTS[:likely_damaged] += 1
80
- puts "LIKELY DAMAGED: #{file_path}"
85
+ STDERR.puts "LIKELY DAMAGED: #{file_path}"
81
86
  else
82
87
  COUNTS[:updated] += 1
83
- puts "UPDATED: #{file_path}" if VERBOSE || TEST_ONLY
88
+ puts "UPDATED: #{file_path}" unless QUIET
84
89
  unless TEST_ONLY
85
90
  @update_mtime_and_digest.execute mtime, digest, found['id']
86
91
  end
@@ -88,7 +93,7 @@ class DigestDatabase
88
93
  end
89
94
  else
90
95
  COUNTS[:new] += 1
91
- puts "NEW: #{file_path}" if VERBOSE || TEST_ONLY
96
+ puts "NEW: #{file_path}" unless QUIET
92
97
  unless TEST_ONLY
93
98
  @new_files[file_path] = digest
94
99
  @insert.execute! file_path, mtime, digest
@@ -133,7 +138,7 @@ class Checker
133
138
  @digest_database_path = digest_database_path
134
139
  ensure_dir_exists @digest_database_path.dirname
135
140
  else
136
- @digest_database_path = @files_path + 'file-digests.sqlite'
141
+ @digest_database_path = @files_path + '.file-digests.sqlite'
137
142
  @skip_file_digests_sqlite = true
138
143
  end
139
144
 
@@ -156,7 +161,9 @@ class Checker
156
161
  def walk_files
157
162
  Dir.glob(@files_path + '**' + '*', File::FNM_DOTMATCH) do |filename|
158
163
  next unless File.file? filename
159
- next if @skip_file_digests_sqlite && filename == 'file-digests.sqlite'
164
+ next if @skip_file_digests_sqlite && filename == '.file-digests.sqlite'
165
+ next if @skip_file_digests_sqlite && filename == '.file-digests.sqlite-wal'
166
+ next if @skip_file_digests_sqlite && filename == '.file-digests.sqlite-shm'
160
167
  yield filename
161
168
  end
162
169
  end
@@ -182,7 +189,7 @@ class Checker
182
189
 
183
190
  end
184
191
 
185
- VERBOSE = (ENV["VERBOSE"] == "true")
192
+ QUIET = (ENV["QUIET"] == "true")
186
193
  TEST_ONLY = (ENV["TEST_ONLY"] == "true")
187
194
 
188
195
  COUNTS = {good: 0, updated: 0, new: 0, missing: 0, renamed: 0, likely_damaged: 0, exceptions: 0}
@@ -202,7 +209,7 @@ begin
202
209
  end
203
210
 
204
211
  if COUNTS[:likely_damaged] > 0 || COUNTS[:exceptions] > 0
205
- puts "ERRORS WERE OCCURRED, PLEASE CHECK FOR THEM"
212
+ STDERR.puts "ERRORS WERE OCCURRED"
206
213
  end
207
214
 
208
215
  puts COUNTS.inspect
@@ -21,7 +21,7 @@ def measure_time
21
21
  start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
22
22
  yield
23
23
  elapsed = (Process.clock_gettime(Process::CLOCK_MONOTONIC) - start).to_i
24
- puts "Elapsed time: #{elapsed / 3600}h #{(elapsed % 3600) / 60}m #{elapsed % 60}s" if VERBOSE
24
+ puts "Elapsed time: #{elapsed / 3600}h #{(elapsed % 3600) / 60}m #{elapsed % 60}s" unless QUIET
25
25
  end
26
26
 
27
27
  def patch_path_string path
@@ -43,6 +43,11 @@ class DigestDatabase
43
43
  @db.execute "CREATE UNIQUE INDEX digests_filename ON digests(filename)"
44
44
  end
45
45
 
46
+ @db.execute 'PRAGMA journal_mode = "WAL"'
47
+ @db.execute 'PRAGMA synchronous = "NORMAL"'
48
+ @db.execute 'PRAGMA locking_mode = "EXCLUSIVE"'
49
+ @db.execute 'PRAGMA cache_size = "5000"'
50
+
46
51
  @db.results_as_hash = true
47
52
  @missing_files = Hash[@db.prepare("SELECT filename, digest FROM digests").execute!]
48
53
  @new_files = {}
@@ -66,7 +71,7 @@ class DigestDatabase
66
71
 
67
72
  if found['digest'] == digest
68
73
  COUNTS[:good] += 1
69
- puts "GOOD: #{file_path}" if VERBOSE
74
+ # puts "GOOD: #{file_path}" unless QUIET
70
75
  unless TEST_ONLY
71
76
  if found['mtime'] == mtime
72
77
  @touch_digest_check_time.execute found['id']
@@ -77,10 +82,10 @@ class DigestDatabase
77
82
  else
78
83
  if found['mtime'] == mtime # Digest is different and mtime is the same
79
84
  COUNTS[:likely_damaged] += 1
80
- puts "LIKELY DAMAGED: #{file_path}"
85
+ STDERR.puts "LIKELY DAMAGED: #{file_path}"
81
86
  else
82
87
  COUNTS[:updated] += 1
83
- puts "UPDATED: #{file_path}" if VERBOSE || TEST_ONLY
88
+ puts "UPDATED: #{file_path}" unless QUIET
84
89
  unless TEST_ONLY
85
90
  @update_mtime_and_digest.execute mtime, digest, found['id']
86
91
  end
@@ -88,7 +93,7 @@ class DigestDatabase
88
93
  end
89
94
  else
90
95
  COUNTS[:new] += 1
91
- puts "NEW: #{file_path}" if VERBOSE || TEST_ONLY
96
+ puts "NEW: #{file_path}" unless QUIET
92
97
  unless TEST_ONLY
93
98
  @new_files[file_path] = digest
94
99
  @insert.execute! file_path, mtime, digest
@@ -133,7 +138,7 @@ class Checker
133
138
  @digest_database_path = digest_database_path
134
139
  ensure_dir_exists @digest_database_path.dirname
135
140
  else
136
- @digest_database_path = @files_path + 'file-digests.sqlite'
141
+ @digest_database_path = @files_path + '.file-digests.sqlite'
137
142
  @skip_file_digests_sqlite = true
138
143
  end
139
144
 
@@ -156,7 +161,9 @@ class Checker
156
161
  def walk_files
157
162
  Dir.glob(@files_path + '**' + '*', File::FNM_DOTMATCH) do |filename|
158
163
  next unless File.file? filename
159
- next if @skip_file_digests_sqlite && filename == 'file-digests.sqlite'
164
+ next if @skip_file_digests_sqlite && filename == '.file-digests.sqlite'
165
+ next if @skip_file_digests_sqlite && filename == '.file-digests.sqlite-wal'
166
+ next if @skip_file_digests_sqlite && filename == '.file-digests.sqlite-shm'
160
167
  yield filename
161
168
  end
162
169
  end
@@ -182,7 +189,7 @@ class Checker
182
189
 
183
190
  end
184
191
 
185
- VERBOSE = (ENV["VERBOSE"] == "true")
192
+ QUIET = (ENV["QUIET"] == "true")
186
193
  TEST_ONLY = true
187
194
 
188
195
  COUNTS = {good: 0, updated: 0, new: 0, missing: 0, renamed: 0, likely_damaged: 0, exceptions: 0}
@@ -202,7 +209,7 @@ begin
202
209
  end
203
210
 
204
211
  if COUNTS[:likely_damaged] > 0 || COUNTS[:exceptions] > 0
205
- puts "ERRORS WERE OCCURRED, PLEASE CHECK FOR THEM"
212
+ STDERR.puts "ERRORS WERE OCCURRED"
206
213
  end
207
214
 
208
215
  puts COUNTS.inspect
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: file-digests
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stanislav Senotrusov
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2020-10-08 00:00:00.000000000 Z
@@ -38,7 +38,7 @@ homepage: https://github.com/senotrusov/file-digests
38
38
  licenses:
39
39
  - Apache-2.0
40
40
  metadata: {}
41
- post_install_message:
41
+ post_install_message:
42
42
  rdoc_options: []
43
43
  require_paths:
44
44
  - lib
@@ -54,7 +54,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
54
54
  version: '0'
55
55
  requirements: []
56
56
  rubygems_version: 3.1.2
57
- signing_key:
57
+ signing_key:
58
58
  specification_version: 4
59
59
  summary: file-digests
60
60
  test_files: []