Commit 8ca54d41 by yexing

加速上传

parent cf92a603
3.4.9
\ No newline at end of file
3.5.0
\ No newline at end of file
No preview for this file type
......@@ -19631,7 +19631,7 @@
if (options.isCheck && !await checkLog(fn)) return;
const insert = await retry(
async () => upload(url, data, options.headers),
{ delayMs: 1000 * 60 * 1.5, retries: 10 }
{ delayMs: 1000 * 10, retries: 10 }
);
if (insert) await checkLog(fn, true);
}
......
......@@ -1285,7 +1285,7 @@ var G = (function (exports) {
if (options.isCheck && !await checkLog(fn)) return;
const insert = await retry(
async () => upload(url, data, options.headers),
{ delayMs: 1000 * 60 * 1.5, retries: 10 }
{ delayMs: 1000 * 10, retries: 10 }
);
if (insert) await checkLog(fn, true);
}
......@@ -1308,7 +1308,7 @@ var G = (function (exports) {
let tasks = await createTasks(uri, fromDate, toDate);
tasks = sn ? [tasks.at(sn)] : tasks;
let moment = 2000, idx = 0, len = tasks.length;
const allData = [], allFn = [], zipFn = `${Task.partnerId} #${key}# ${fromDate}_${toDate}.zip`;
const allData = [], allFn = [], allUp = [], zipFn = `${Task.partnerId} #${key}# ${fromDate}_${toDate}.zip`;
const isSingle = uri == TABLE.PAYMENT.uri;
for (const task of tasks) {
const pf = `${++idx}/${len}`;
......@@ -1337,18 +1337,14 @@ var G = (function (exports) {
const route = data.__route;
delete data.__route;
const headers = { 'Content-Type': 'application/json' };
await uploadFile(fn, data, { isJson, headers, route });
if (isDownload) {
// const blob = new Blob([data], { "type": "application/json" });
// downloadFile(fn, blob);
allUp.push(uploadFile(fn, data, { isJson, headers, route }));
console.log(data);
}
} else {
if (isSingle) {
const zip = await createZip([data], [fn]);
const form = new FormData();
form.append("zipfile", zip, fn);
await uploadFile(fn, form);
allUp.push(uploadFile(fn, form));
} else {
allData.push(data);
allFn.push(fn);
......@@ -1361,9 +1357,10 @@ var G = (function (exports) {
const zip = await createZip(allData, allFn);
const form = new FormData();
form.append("zipfile", zip, zipFn);
await uploadFile(zipFn, form, { isCheck: true });
allUp.push(uploadFile(zipFn, form, { isCheck: true }));
isDownload && downloadFile(zipFn, zip);
}
await Promise.all(allUp);
addLog(`${name} 运行完成`);
}
if (typeof chrome !== 'undefined' && chrome.runtime) {
......
{"name":"WalmartExports","description":"导出沃尔玛报表","version":"3.4.9","manifest_version":3,"background":{"service_worker":"./js/background.js"},"permissions":["tabs","activeTab","scripting","notifications","storage","alarms"],"action":{"default_title":"WalmartExports","default_popup":"popup.html","default_icon":{"16":"icon.png","32":"icon.png","48":"icon.png","128":"icon.png"}},"icons":{"16":"icon.png","32":"icon.png","48":"icon.png","128":"icon.png"},"web_accessible_resources":[{"resources":["src/main.js"],"matches":["<all_urls>"]}],"host_permissions":["https://seller.walmart.com/*","https://advertising.walmart.com/*","https://login.account.wal-mart.com/*","https://marketplace.walmartapis.com/*","https://walmart.meinuosha.com/*"],"content_scripts":[{"matches":["https://seller.walmart.com/*","https://advertising.walmart.com/*","https://login.account.wal-mart.com/*","https://marketplace.walmartapis.com/*","https://walmart.meinuosha.com/*"],"js":["./js/main.js"]}]}
\ No newline at end of file
{"name":"WalmartExports","description":"导出沃尔玛报表","version":"3.5.0","manifest_version":3,"background":{"service_worker":"./js/background.js"},"permissions":["tabs","activeTab","scripting","notifications","storage","alarms"],"action":{"default_title":"WalmartExports","default_popup":"popup.html","default_icon":{"16":"icon.png","32":"icon.png","48":"icon.png","128":"icon.png"}},"icons":{"16":"icon.png","32":"icon.png","48":"icon.png","128":"icon.png"},"web_accessible_resources":[{"resources":["src/main.js"],"matches":["<all_urls>"]}],"host_permissions":["https://seller.walmart.com/*","https://advertising.walmart.com/*","https://login.account.wal-mart.com/*","https://marketplace.walmartapis.com/*","https://walmart.meinuosha.com/*"],"content_scripts":[{"matches":["https://seller.walmart.com/*","https://advertising.walmart.com/*","https://login.account.wal-mart.com/*","https://marketplace.walmartapis.com/*","https://walmart.meinuosha.com/*"],"js":["./js/main.js"]}]}
\ No newline at end of file
......@@ -24,7 +24,7 @@ export async function run(options = {}) {
let tasks = await createTasks(uri, fromDate, toDate);
tasks = sn ? [tasks.at(sn)] : tasks;
let moment = 2000, idx = 0, len = tasks.length;
const allData = [], allFn = [], zipFn = `${Task.partnerId} #${key}# ${fromDate}_${toDate}.zip`;
const allData = [], allFn = [], allUp = [], zipFn = `${Task.partnerId} #${key}# ${fromDate}_${toDate}.zip`;
const isSingle = uri == TABLE.PAYMENT.uri;
for (const task of tasks) {
const pf = `${++idx}/${len}`;
......@@ -53,18 +53,14 @@ export async function run(options = {}) {
const route = data.__route;
delete data.__route;
const headers = { 'Content-Type': 'application/json' }
await uploadFile(fn, data, { isJson, headers, route });
if (isDownload) {
// const blob = new Blob([data], { "type": "application/json" });
// downloadFile(fn, blob);
allUp.push(uploadFile(fn, data, { isJson, headers, route }));
console.log(data);
}
} else {
if (isSingle) {
const zip = await createZip([data], [fn]);
const form = new FormData();
form.append("zipfile", zip, fn);
await uploadFile(fn, form);
allUp.push(uploadFile(fn, form));
} else {
allData.push(data);
allFn.push(fn);
......@@ -77,9 +73,10 @@ export async function run(options = {}) {
const zip = await createZip(allData, allFn);
const form = new FormData();
form.append("zipfile", zip, zipFn);
await uploadFile(zipFn, form, { isCheck: true });
allUp.push(uploadFile(zipFn, form, { isCheck: true }));
isDownload && downloadFile(zipFn, zip);
}
await Promise.all(allUp);
addLog(`${name} 运行完成`);
}
if (typeof chrome !== 'undefined' && chrome.runtime) {
......
......@@ -43,7 +43,7 @@ export async function uploadFile(fn, data, options = {}) {
if (options.isCheck && !await checkLog(fn)) return;
const insert = await retry(
async () => upload(url, data, options.headers),
{ delayMs: 1000 * 60 * 1.5, retries: 10 }
{ delayMs: 1000 * 10, retries: 10 }
);
if (insert) await checkLog(fn, true);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment