MCPcopy Index your code
hub / github.com/Firstyear/opensuse-proxy-cache / prefetch

Method prefetch

opensuse-proxy-cache/src/cache.rs:122–197  ·  view source on GitHub ↗
(
        &self,

        context: &Backend,
        path: &Path,

        pri_cache: &ArcDiskCache<PathBuf, Status>,
        _complete: bool,
    )

Source from the content-addressed store, hash-verified

120
121impl Classification {
122 fn prefetch(
123 &self,
124
125 context: &Backend,
126 path: &Path,
127
128 pri_cache: &ArcDiskCache<PathBuf, Status>,
129 _complete: bool,
130 ) -> Option<Vec<PrefetchItem>> {
131 match self {
132 Classification::RepomdXmlSlow | Classification::RepomdXmlFast => {
133 path.parent().and_then(|p| p.parent()).map(|p| {
134 let mut v = vec![];
135 if let Some(tmp_file) = pri_cache.new_tempfile() {
136 let cache_key = p.join("media.1/media");
137 let cls = Classification::Metadata;
138 let mut fetch_url = context.provider.clone();
139 fetch_url.set_path(&cache_key.to_string_lossy());
140 v.push(PrefetchItem {
141 fetch_url,
142 cache_key,
143 tmp_file,
144 cls,
145 })
146 };
147
148 if let Some(tmp_file) = pri_cache.new_tempfile() {
149 let cache_key = p.join("repodata/repomd.xml.asc");
150 let cls = Classification::Metadata;
151 let mut fetch_url = context.provider.clone();
152 fetch_url.set_path(&cache_key.to_string_lossy());
153 v.push(PrefetchItem {
154 fetch_url,
155 cache_key,
156 tmp_file,
157 cls,
158 })
159 };
160
161 if let Some(tmp_file) = pri_cache.new_tempfile() {
162 let cache_key = p.join("repodata/repomd.xml.key");
163 let cls = Classification::Metadata;
164 let mut fetch_url = context.provider.clone();
165 fetch_url.set_path(&cache_key.to_string_lossy());
166 v.push(PrefetchItem {
167 fetch_url,
168 cache_key,
169 tmp_file,
170 cls,
171 })
172 };
173
174 if let Some(tmp_file) = pri_cache.new_tempfile() {
175 let cache_key = p.join("repodata/repomd.xml");
176 let cls = Classification::Metadata;
177 let mut fetch_url = context.provider.clone();
178 fetch_url.set_path(&cache_key.to_string_lossy());
179 v.push(PrefetchItem {

Callers 1

decisionMethod · 0.80

Calls 1

new_tempfileMethod · 0.80

Tested by

no test coverage detected