You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/scenic/cache/file.ex
+10-11Lines changed: 10 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -47,11 +47,6 @@ defmodule Scenic.Cache.File do
47
47
and to store the result in your applications code itself. Then during run time, you
48
48
compare then pre-computed hash against the run-time of the asset being loaded.
49
49
50
-
Please take advantage of the helper modules [`Cache.File`](Scenic.Cache.File.html),
51
-
[`Cache.Term`](Scenic.Cache.Term.html), and [`Cache.Hash`](Scenic.Cache.Hash.html) to
52
-
do this for you. These modules load files and insert them into the cache while checking
53
-
a precomputed hash.
54
-
55
50
These scheme is much stronger when the application code itself is also signed and
56
51
verified, but that is an exercise for the packaging tools.
57
52
@@ -86,7 +81,6 @@ defmodule Scenic.Cache.File do
86
81
87
82
end
88
83
"""
89
-
90
84
aliasScenic.Cache
91
85
aliasScenic.Cache.Hash
92
86
@@ -100,8 +94,9 @@ defmodule Scenic.Cache.File do
100
94
* `opts` - a list of options. See below.
101
95
102
96
Options:
103
-
* `hash` - format of the hash. Valid formats include `:sha, :sha224, :sha256, :sha384, :sha512, :ripemd160`
97
+
* `hash` - format of the hash. Valid formats include `:sha, :sha224, :sha256, :sha384, :sha512, :ripemd160`. If the hash option is not set, it will use `:sha` by default.
104
98
* `scope` - Explicitly set the scope of the asset in the cache.
99
+
* `decompress` - if `true` - decompress the data (zlib) after reading and verifying the hash.
105
100
106
101
On success, returns
107
102
`{:ok, cache_key}`
@@ -115,7 +110,9 @@ defmodule Scenic.Cache.File do
115
110
# hashes. Is also slower because it has to load the file and compute the hash
116
111
# to use as a key even it is is already loaded into the cache.
117
112
defload(path,:insecure,opts)do
118
-
IO.puts"WARNING: Cache asset loaded as :insecure \"#{path}\""
113
+
ifMix.env!=:testdo
114
+
IO.puts"WARNING: Cache asset loaded as :insecure \"#{path}\""
115
+
end
119
116
with{:ok,data}<-read(path,:insecure,opts)do
120
117
hash=Hash.binary(data,opts[:hash]||:sha)
121
118
@@ -161,8 +158,8 @@ defmodule Scenic.Cache.File do
161
158
* `opts` - a list of options. See below.
162
159
163
160
Options:
164
-
* `hash` - format of the hash. Valid formats include `:sha, :sha224, :sha256, :sha384, :sha512, :ripemd160`
165
-
* `decompress` - if true - decompress the data (zlib) after reading and verifying the hash.
161
+
* `hash` - format of the hash. Valid formats include `:sha, :sha224, :sha256, :sha384, :sha512, :ripemd160`. If the hash option is not set, it will use `:sha` by default.
162
+
* `decompress` - if `true` - decompress the data (zlib) after reading and verifying the hash.
166
163
167
164
On success, returns
168
165
`{:ok, data}`
@@ -175,7 +172,9 @@ defmodule Scenic.Cache.File do
175
172
# hashes. Is also slower because it has to load the file and compute the hash
176
173
# to use as a key even it is is already loaded into the cache.
177
174
defread(path,:insecure,opts)do
178
-
IO.puts"WARNING: Cache asset read as :insecure \"#{path}\""
175
+
ifMix.env()!=:testdo
176
+
IO.puts"WARNING: Cache asset read as :insecure \"#{path}\""
0 commit comments