assiette 0.6.0 → 0.6.1

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: b94d7ebde46d04a55abfd53f02d95c2eb6b4d4df1bda833c98089afbefd1ab1b
4
- data.tar.gz: 342adfcac7ade1a593af2f887883314bd35d1ccae4e87f91e503c0008e8db46a
3
+ metadata.gz: 0e320ec60ec5cb1469b38e4bc4bcfc707f1fa044e219e7aee6c94f7a01154e9f
4
+ data.tar.gz: d73852fffc343121cc86b6e3d6cf1be17c3d9297eada8bc210c858409037345c
5
5
  SHA512:
6
- metadata.gz: 26ede00337abc21c2ee238e0e99d7d2143d61cbae84eac72d22210f16cd373c0a41056a9edad881b6a6f049acb353e96605cde191238b6ea643998a4cb255db9
7
- data.tar.gz: 7c5507d623a0cc264ecbd8f5776a71aef7ad001753d1117c9e0f8cced9fcbc67542a447d4faca3152d89109cea5e2175fc1a72d564aff1cfc22c2f5162e63361
6
+ metadata.gz: 1c7591ac6ecc0e9390200a8e567b5fcc8c6c325b67784fe6521a5104f181f2639074cdb5dce319bef10961d94b1c21dc08dfec136fc6628da544b6ad10aec0d0
7
+ data.tar.gz: cb7a98754dd1617e0d1cb18948ab5b81a8264a0c058fad121089d0b8480a84be64e77ff65b051e09bbc5fe030d9db85f246c54451710f600f32182f1ad8c6b92
@@ -155,7 +155,7 @@ module Assiette
155
155
  end
156
156
 
157
157
  if existing.stale?
158
- rescan_asset!(existing)
158
+ return nil unless rescan_asset!(existing)
159
159
  @checked << url_path
160
160
  return existing
161
161
  end
@@ -239,9 +239,12 @@ module Assiette
239
239
  end
240
240
 
241
241
  # Re-read a stale asset, re-parse deps, recursively ensure deps fresh, recompute digest.
242
+ # Returns false if the file went away while we were looking at it.
242
243
  def rescan_asset!(asset)
243
244
  url_path = asset.url_path
244
- asset.mtime = File.mtime(asset.abs_path)
245
+ raw, mtime = read_or_drop!(asset)
246
+ return false unless raw
247
+ asset.mtime = mtime
245
248
 
246
249
  # Remove old reverse links
247
250
  asset.deps.each do |dep_path|
@@ -249,8 +252,6 @@ module Assiette
249
252
  dep&.dependents&.delete(url_path)
250
253
  end
251
254
 
252
- # Re-parse imports
253
- raw = File.read(asset.abs_path)
254
255
  asset.deps = parse_deps(url_path, raw)
255
256
 
256
257
  # Recursively ensure deps are fresh
@@ -267,6 +268,14 @@ module Assiette
267
268
  end
268
269
 
269
270
  # Recompute digests for all transitive dependents of an asset.
271
+ #
272
+ # A dependent whose own file has since gone is dropped rather than
273
+ # recomputed. Nothing ever resolves an orphan from above — it is only
274
+ # reached from below, through this very walk — so without this a file
275
+ # renamed away lingers in the graph as an importer, and the next edit to
276
+ # anything it used to import tries to read a path that is not there. Its
277
+ # own dependents still have to hear about it: they keep the vanished node
278
+ # in their deps until they are rescanned, and it rewrites to 00000000 now.
270
279
  def propagate_to_dependents!(asset)
271
280
  queue = asset.dependents.to_a
272
281
  visited = Set.new
@@ -274,8 +283,12 @@ module Assiette
274
283
  next unless visited.add?(dep_url)
275
284
  dep_asset = @assets[dep_url]
276
285
  next unless dep_asset
277
- compute_digest_for(dep_url)
278
286
  queue.concat(dep_asset.dependents.to_a)
287
+ if dep_asset.deleted?
288
+ remove_asset!(dep_url)
289
+ else
290
+ compute_digest_for(dep_url)
291
+ end
279
292
  end
280
293
  end
281
294
 
@@ -289,11 +302,26 @@ module Assiette
289
302
  import_paths.map { |p| resolve_import_for(url_path, p) }
290
303
  end
291
304
 
305
+ # Reads an asset's bytes, together with the mtime they were read at, and
306
+ # returns nil after dropping the node if the file is not there any more.
307
+ #
308
+ # Every read of a path the graph remembers goes through here. Those paths
309
+ # come from an earlier request, and while the server is up any of them can
310
+ # be renamed or deleted between two renders — a disappearance has to read
311
+ # as "gone from the graph", never as an exception out of a view helper.
312
+ def read_or_drop!(asset)
313
+ [File.read(asset.abs_path), File.mtime(asset.abs_path)]
314
+ rescue Errno::ENOENT
315
+ remove_asset!(asset.url_path)
316
+ nil
317
+ end
318
+
292
319
  def compute_digest_for(url_path)
293
320
  asset = @assets[url_path]
294
321
  return unless asset
295
322
 
296
- raw = File.read(asset.abs_path)
323
+ raw, _mtime = read_or_drop!(asset)
324
+ return unless raw
297
325
  if asset.deps.empty?
298
326
  asset.digest = Digest::SHA256.digest(raw)
299
327
  else
@@ -307,7 +335,7 @@ module Assiette
307
335
  combined = scc.sort.filter_map { |url_path|
308
336
  asset = @assets[url_path]
309
337
  next unless asset
310
- File.read(asset.abs_path)
338
+ read_or_drop!(asset)&.first
311
339
  }.join("\0")
312
340
 
313
341
  digest = Digest::SHA256.digest(combined)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Assiette
4
- VERSION = "0.6.0"
4
+ VERSION = "0.6.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assiette
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julik Tarkhanov
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2026-09-13 00:00:00.000000000 Z
10
+ date: 2026-09-21 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: actionpack
@@ -54,7 +53,6 @@ metadata:
54
53
  homepage_uri: https://github.com/julik/assiette
55
54
  source_code_uri: https://github.com/julik/assiette
56
55
  changelog_uri: https://github.com/julik/assiette/blob/main/CHANGELOG.md
57
- post_install_message:
58
56
  rdoc_options: []
59
57
  require_paths:
60
58
  - lib
@@ -69,8 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
67
  - !ruby/object:Gem::Version
70
68
  version: '0'
71
69
  requirements: []
72
- rubygems_version: 3.4.10
73
- signing_key:
70
+ rubygems_version: 3.6.6
74
71
  specification_version: 4
75
72
  summary: Zero-build asset serving for Rails engines
76
73
  test_files: []