MCPcopy Index your code
hub / github.com/apache/pouchdb / getDocAttachmentsFromTargetOrSource

Function getDocAttachmentsFromTargetOrSource

lib/index-browser.js:9253–9277  ·  view source on GitHub ↗
(target, src, doc)

Source from the content-addressed store, hash-verified

9251}
9252
9253function getDocAttachmentsFromTargetOrSource(target, src, doc) {
9254 var doCheckForLocalAttachments = isRemote(src) && !isRemote(target);
9255 var filenames = Object.keys(doc._attachments);
9256
9257 if (!doCheckForLocalAttachments) {
9258 return getDocAttachments(src, doc);
9259 }
9260
9261 return target.get(doc._id).then(function (localDoc) {
9262 return Promise.all(filenames.map(function (filename) {
9263 if (fileHasChanged(localDoc, doc, filename)) {
9264 return src.getAttachment(doc._id, filename);
9265 }
9266
9267 return target.getAttachment(localDoc._id, filename);
9268 }));
9269 }).catch(function (error) {
9270 /* istanbul ignore if */
9271 if (error.status !== 404) {
9272 throw error;
9273 }
9274
9275 return getDocAttachments(src, doc);
9276 });
9277}
9278
9279function createBulkGetOpts(diffs) {
9280 var requests = [];

Callers 1

getAllDocsFunction · 0.70

Calls 4

isRemoteFunction · 0.70
getDocAttachmentsFunction · 0.70
fileHasChangedFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…