Commit 4d203b4e authored by Michał "rysiek" Woźniak's avatar Michał "rysiek" Woźniak
Browse files

SamizdatResourceInfo.method returns a Promise...

parent e787e249
Pipeline #1955 passed with stage
in 4 minutes and 8 seconds
......@@ -225,24 +225,27 @@ self.addEventListener('fetch', event => {
for (i=0; i<SamizdatPlugins.length; i++) {
if (typeof SamizdatPlugins[i].stash === 'function') {
// if we got this from the same stashing plugin in the first place, this is moot
if (SamizdatInfo.resources[cleanURL].method === SamizdatPlugins[i].name) {
console.log('(COMMIT_UNKNOWN) Not stashing, since resource is retrieved by a stashing plugin:', cleanURL);
return response
}
// ok, now we're in business
console.log('(COMMIT_UNKNOWN) Stashing a successful fetch of:', cleanURL);
console.log('+-- fetched using :', SamizdatInfo.resources[cleanURL].method)
console.log('+-- stashing using :', SamizdatPlugins[i].name)
// working on clone()'ed response so that the original one is not touched
// TODO: should a failed stashing break the flow here? probably not!
return SamizdatPlugins[i].stash(response.clone(), cleanURL)
.then((res)=>{
// original response will be needed further down
// yes, this returns a promise...
return SamizdatInfo.resources[cleanURL].method.then((method)=>{
// if we got this from the same stashing plugin in the first place, this is moot
if (method === SamizdatPlugins[i].name) {
console.log('(COMMIT_UNKNOWN) Not stashing, since resource is retrieved by a stashing plugin:', cleanURL);
return response
})
}
// ok, now we're in business
console.log('(COMMIT_UNKNOWN) Stashing a successful fetch of:', cleanURL);
console.log('+-- fetched using :', method)
console.log('+-- stashing using :', SamizdatPlugins[i].name)
// working on clone()'ed response so that the original one is not touched
// TODO: should a failed stashing break the flow here? probably not!
return SamizdatPlugins[i].stash(response.clone(), cleanURL)
.then((res)=>{
// original response will be needed further down
return response
})
})
}
}
// if we're here it means we went through the whole list of plugins
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment