Changeset View
Changeset View
Standalone View
Standalone View
assets/src/bundles/vault/vault-ui.js
Show First 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | export async function recookObject() { | ||||
if (recookTask) { | if (recookTask) { | ||||
// stop cooking tasks status polling | // stop cooking tasks status polling | ||||
clearTimeout(checkVaultId); | clearTimeout(checkVaultId); | ||||
// build cook request url | // build cook request url | ||||
let cookingUrl; | let cookingUrl; | ||||
if (recookTask.bundle_type === 'flat') { | if (recookTask.bundle_type === 'flat') { | ||||
cookingUrl = Urls.api_1_vault_cook_flat(recookTask.swhid); | cookingUrl = Urls.api_1_vault_cook_flat(recookTask.swhid); | ||||
} else { | } else { | ||||
cookingUrl = Urls.api_1_vault_cook_gitfast(recookTask.swhid); | cookingUrl = Urls.api_1_vault_cook_git_bare(recookTask.swhid); | ||||
} | } | ||||
if (recookTask.email) { | if (recookTask.email) { | ||||
cookingUrl += '?email=' + recookTask.email; | cookingUrl += '?email=' + recookTask.email; | ||||
} | } | ||||
try { | try { | ||||
// request archive cooking | // request archive cooking | ||||
const response = await csrfPost(cookingUrl); | const response = await csrfPost(cookingUrl); | ||||
handleFetchError(response); | handleFetchError(response); | ||||
Show All 38 Lines | for (let i = 0; i < vaultCookingTasks.length; ++i) { | ||||
if (typeof cookingTask.object_type !== 'undefined') { | if (typeof cookingTask.object_type !== 'undefined') { | ||||
// Legacy cooking task, upgrade it to the new schema | // Legacy cooking task, upgrade it to the new schema | ||||
if (cookingTask.object_type === 'directory') { | if (cookingTask.object_type === 'directory') { | ||||
cookingTask.swhid = `swh:1:dir:${cookingTask.object_id}`; | cookingTask.swhid = `swh:1:dir:${cookingTask.object_id}`; | ||||
cookingTask.bundle_type = 'flat'; | cookingTask.bundle_type = 'flat'; | ||||
cookingTask.fetch_url = Urls.api_1_vault_fetch_flat(cookingTask.swhid); | cookingTask.fetch_url = Urls.api_1_vault_fetch_flat(cookingTask.swhid); | ||||
} else if (cookingTask.object_type === 'revision') { | } else if (cookingTask.object_type === 'revision') { | ||||
cookingTask.swhid = `swh:1:rev:${cookingTask.object_id}`; | cookingTask.swhid = `swh:1:rev:${cookingTask.object_id}`; | ||||
cookingTask.bundle_type = 'gitfast'; | cookingTask.bundle_type = 'git_bare'; | ||||
cookingTask.fetch_url = Urls.api_1_vault_fetch_gitfast(cookingTask.swhid); | cookingTask.fetch_url = Urls.api_1_vault_fetch_git_bare(cookingTask.swhid); | ||||
} else { | } else { | ||||
// Log to the console + Sentry | // Log to the console + Sentry | ||||
console.error(`Unexpected cookingTask.object_type: ${cookingTask.object_type}`); | console.error(`Unexpected cookingTask.object_type: ${cookingTask.object_type}`); | ||||
// Ignore it for now and hope a future version will fix it | // Ignore it for now and hope a future version will fix it | ||||
continue; | continue; | ||||
} | } | ||||
delete cookingTask.object_type; | delete cookingTask.object_type; | ||||
delete cookingTask.object_id; | delete cookingTask.object_id; | ||||
} | } | ||||
currentObjectIds.push(cookingTask.swhid); | currentObjectIds.push(cookingTask.swhid); | ||||
tasks[cookingTask.swhid] = cookingTask; | tasks[cookingTask.swhid] = cookingTask; | ||||
let cookingUrl; | let cookingUrl; | ||||
if (cookingTask.bundle_type === 'flat') { | if (cookingTask.bundle_type === 'flat') { | ||||
cookingUrl = Urls.api_1_vault_cook_flat(cookingTask.swhid); | cookingUrl = Urls.api_1_vault_cook_flat(cookingTask.swhid); | ||||
} else { | } else { | ||||
cookingUrl = Urls.api_1_vault_cook_gitfast(cookingTask.swhid); | cookingUrl = Urls.api_1_vault_cook_git_bare(cookingTask.swhid); | ||||
} | } | ||||
if (cookingTask.status !== 'done' && cookingTask.status !== 'failed') { | if (cookingTask.status !== 'done' && cookingTask.status !== 'failed') { | ||||
cookingTaskRequests.push(fetch(cookingUrl)); | cookingTaskRequests.push(fetch(cookingUrl)); | ||||
} | } | ||||
} | } | ||||
$('.swh-vault-table tbody tr').each((i, row) => { | $('.swh-vault-table tbody tr').each((i, row) => { | ||||
const swhid = $(row).find('.vault-object-info').data('swhid'); | const swhid = $(row).find('.vault-object-info').data('swhid'); | ||||
if ($.inArray(swhid, currentObjectIds) === -1) { | if ($.inArray(swhid, currentObjectIds) === -1) { | ||||
▲ Show 20 Lines • Show All 99 Lines • Show Last 20 Lines |