MCPcopy
hub / github.com/apache/pouchdb / doMigrationOne

Function doMigrationOne

lib/index.es.js:6426–6480  ·  view source on GitHub ↗
(name, db, callback)

Source from the content-addressed store, hash-verified

6424var UUID_KEY$1 = '_local_uuid';
6425
6426var doMigrationOne = function (name, db, callback) {
6427 // local require to prevent crashing if leveldown isn't installed.
6428 var leveldown = require("leveldown");
6429
6430 var base = path.resolve(name);
6431 function move(store, index, cb) {
6432 var storePath = path.join(base, store);
6433 var opts;
6434 if (index === 3) {
6435 opts = {
6436 valueEncoding: 'binary'
6437 };
6438 } else {
6439 opts = {
6440 valueEncoding: 'json'
6441 };
6442 }
6443 var sub = db.sublevel(store, opts);
6444 var orig = level(storePath, opts);
6445 var from = orig.createReadStream();
6446 var writeStream = new LevelWriteStream(sub);
6447 var to = writeStream();
6448 from.on('end', function () {
6449 orig.close(function (err) {
6450 cb(err, storePath);
6451 });
6452 });
6453 from.pipe(to);
6454 }
6455 fs.unlink(base + '.uuid', function (err) {
6456 if (err) {
6457 return callback();
6458 }
6459 var todo = 4;
6460 var done = [];
6461 stores.forEach(function (store, i) {
6462 move(store, i, function (err, storePath) {
6463 /* istanbul ignore if */
6464 if (err) {
6465 return callback(err);
6466 }
6467 done.push(storePath);
6468 if (!(--todo)) {
6469 done.forEach(function (item) {
6470 leveldown.destroy(item, function () {
6471 if (++todo === done.length) {
6472 fs.rmdir(base, callback);
6473 }
6474 });
6475 });
6476 }
6477 });
6478 });
6479 });
6480};
6481var doMigrationTwo = function (db, stores, callback) {
6482 var batches = [];
6483 stores.bySeqStore.get(UUID_KEY$1, function (err, value) {

Callers

nothing calls this directly

Calls 2

moveFunction · 0.70
destroyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…