backup: rename back backuplisting.js to backups.js
this was a transitional rename till I figured out how to split it in backuptargets.js
This commit is contained in:
22
src/apps.js
22
src/apps.js
@@ -151,7 +151,7 @@ exports = module.exports = {
|
||||
const appTaskManager = require('./apptaskmanager.js'),
|
||||
archives = require('./archives.js'),
|
||||
assert = require('assert'),
|
||||
backupListing = require('./backuplisting.js'),
|
||||
backups = require('./backups.js'),
|
||||
backupTargets = require('./backuptargets.js'),
|
||||
BoxError = require('./boxerror.js'),
|
||||
constants = require('./constants.js'),
|
||||
@@ -2302,7 +2302,7 @@ async function restore(app, backupId, auditSource) {
|
||||
if (error) throw error;
|
||||
|
||||
// for empty or null backupId, use existing manifest to mimic a reinstall
|
||||
const backupInfo = backupId ? await backupListing.get(backupId) : { manifest: app.manifest };
|
||||
const backupInfo = backupId ? await backups.get(backupId) : { manifest: app.manifest };
|
||||
if (!backupInfo) throw new BoxError(BoxError.BAD_FIELD, 'No such backup');
|
||||
const manifest = backupInfo.manifest;
|
||||
|
||||
@@ -2427,7 +2427,7 @@ async function clone(app, data, user, auditSource) {
|
||||
assert.strictEqual(typeof subdomain, 'string');
|
||||
assert.strictEqual(typeof domain, 'string');
|
||||
|
||||
const backupInfo = await backupListing.get(backupId);
|
||||
const backupInfo = await backups.get(backupId);
|
||||
|
||||
if (!backupInfo) throw new BoxError(BoxError.NOT_FOUND, 'Backup not found');
|
||||
if (!backupInfo.manifest) throw new BoxError(BoxError.EXTERNAL_ERROR, 'Could not detect restore manifest');
|
||||
@@ -2506,7 +2506,7 @@ async function unarchive(archive, data, auditSource) {
|
||||
assert.strictEqual(typeof data, 'object');
|
||||
assert(auditSource && typeof auditSource === 'object');
|
||||
|
||||
const backup = await backupListing.get(archive.backupId);
|
||||
const backup = await backups.get(archive.backupId);
|
||||
const restoreConfig = { remotePath: backup.remotePath, backupFormat: backup.format };
|
||||
|
||||
const subdomain = data.subdomain.toLowerCase(),
|
||||
@@ -2602,7 +2602,7 @@ async function archive(app, backupId, auditSource) {
|
||||
|
||||
if (app.manifest.id === constants.PROXY_APP_APPSTORE_ID) throw new BoxError(BoxError.BAD_FIELD, 'cannot archive proxy app');
|
||||
|
||||
const result = await backupListing.getByIdentifierAndStatePaged(app.id, backupListing.BACKUP_STATE_NORMAL, 1, 1);
|
||||
const result = await backups.getByIdentifierAndStatePaged(app.id, backups.BACKUP_STATE_NORMAL, 1, 1);
|
||||
if (result.length === 0) throw new BoxError(BoxError.BAD_STATE, 'No recent backup to archive');
|
||||
if (result[0].id !== backupId) throw new BoxError(BoxError.BAD_STATE, 'Latest backup id has changed');
|
||||
|
||||
@@ -2789,7 +2789,7 @@ async function backup(app, auditSource) {
|
||||
// background
|
||||
tasks.startTask(taskId, { timeout: 24 * 60 * 60 * 1000 /* 24 hours */, nice: 15, memoryLimit, oomScoreAdjust: -999 })
|
||||
.then(async (backupId) => {
|
||||
const backup = await backupListing.get(backupId); // if task crashed, no result
|
||||
const backup = await backups.get(backupId); // if task crashed, no result
|
||||
await eventlog.add(eventlog.ACTION_APP_BACKUP_FINISH, auditSource, { app, success: !!backup, errorMessage: '', remotePath: backup?.remotePath, backupId: backupId });
|
||||
})
|
||||
.catch(async (error) => {
|
||||
@@ -2809,7 +2809,7 @@ async function listBackups(app, page, perPage) {
|
||||
assert(typeof page === 'number' && page > 0);
|
||||
assert(typeof perPage === 'number' && perPage > 0);
|
||||
|
||||
return await backupListing.getByIdentifierAndStatePaged(app.id, backupListing.BACKUP_STATE_NORMAL, page, perPage);
|
||||
return await backups.getByIdentifierAndStatePaged(app.id, backups.BACKUP_STATE_NORMAL, page, perPage);
|
||||
}
|
||||
|
||||
async function updateBackup(app, backupId, data) {
|
||||
@@ -2817,18 +2817,18 @@ async function updateBackup(app, backupId, data) {
|
||||
assert.strictEqual(typeof backupId, 'string');
|
||||
assert.strictEqual(typeof data, 'object');
|
||||
|
||||
const backup = await backupListing.get(backupId);
|
||||
const backup = await backups.get(backupId);
|
||||
if (!backup) throw new BoxError(BoxError.NOT_FOUND, 'Backup not found');
|
||||
if (backup.identifier !== app.id) throw new BoxError(BoxError.NOT_FOUND, 'Backup not found'); // some other app's backup
|
||||
|
||||
await backupListing.update(backupId, data);
|
||||
await backups.update(backupId, data);
|
||||
}
|
||||
|
||||
async function getBackupDownloadStream(app, backupId) {
|
||||
assert.strictEqual(typeof app, 'object');
|
||||
assert.strictEqual(typeof backupId, 'string');
|
||||
|
||||
const backup = await backupListing.get(backupId);
|
||||
const backup = await backups.get(backupId);
|
||||
if (!backup) throw new BoxError(BoxError.NOT_FOUND, 'Backup not found');
|
||||
if (backup.identifier !== app.id) throw new BoxError(BoxError.NOT_FOUND, 'Backup not found'); // some other app's backup
|
||||
if (backup.format !== 'tgz') throw new BoxError(BoxError.BAD_STATE, 'only tgz backups can be downloaded');
|
||||
@@ -2860,7 +2860,7 @@ async function restoreApps(apps, options, auditSource) {
|
||||
apps = apps.filter(app => app.installationState !== exports.ISTATE_PENDING_RESTORE); // safeguard against tasks being created non-stop if we crash on startup
|
||||
|
||||
for (const app of apps) {
|
||||
const [error, result] = await safe(backupListing.getByIdentifierAndStatePaged(app.id, backupListing.BACKUP_STATE_NORMAL, 1, 1));
|
||||
const [error, result] = await safe(backups.getByIdentifierAndStatePaged(app.id, backups.BACKUP_STATE_NORMAL, 1, 1));
|
||||
let installationState, restoreConfig, oldManifest;
|
||||
if (!error && result.length) {
|
||||
installationState = exports.ISTATE_PENDING_RESTORE;
|
||||
|
||||
Reference in New Issue
Block a user