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

Function getDocAttachmentsFromTargetOrSource

lib/index.es.js:9286–9310  ·  view source on GitHub ↗
(target, src, doc)

Source from the content-addressed store, hash-verified

9284}
9285
9286function getDocAttachmentsFromTargetOrSource(target, src, doc) {
9287 var doCheckForLocalAttachments = isRemote(src) && !isRemote(target);
9288 var filenames = Object.keys(doc._attachments);
9289
9290 if (!doCheckForLocalAttachments) {
9291 return getDocAttachments(src, doc);
9292 }
9293
9294 return target.get(doc._id).then(function (localDoc) {
9295 return Promise.all(filenames.map(function (filename) {
9296 if (fileHasChanged(localDoc, doc, filename)) {
9297 return src.getAttachment(doc._id, filename);
9298 }
9299
9300 return target.getAttachment(localDoc._id, filename);
9301 }));
9302 }).catch(function (error) {
9303 /* istanbul ignore if */
9304 if (error.status !== 404) {
9305 throw error;
9306 }
9307
9308 return getDocAttachments(src, doc);
9309 });
9310}
9311
9312function createBulkGetOpts(diffs) {
9313 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…