mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-12 03:14:09 +00:00
feat: enhance extension API (#1413)
This commit is contained in:
10 files changed
+96
-46
No files matched your search
@@ -1,4 +1,7 @@
|
||||
gopeed.events.onResolve(async function (ctx) {
|
||||
ctx.req.setLabels({ replaced: "true", removed: "true" });
|
||||
ctx.req.putLabel("modified", "true");
|
||||
ctx.req.delLabel("removed");
|
||||
ctx.res = {
|
||||
name: "test",
|
||||
files: Array(2).fill(true).map((_, i) => ({
|
||||
|
||||
@@ -132,9 +132,8 @@ gopeed.events.onError(async function (ctx) {
|
||||
return;
|
||||
}
|
||||
|
||||
req.url = createPayloadURL(source, false);
|
||||
req.labels = req.labels || {};
|
||||
req.labels.started = 'true';
|
||||
req.labels.rebuilt = 'true';
|
||||
ctx.task.setUrl(createPayloadURL(source, false));
|
||||
req.putLabel('started', 'true');
|
||||
req.putLabel('rebuilt', 'true');
|
||||
ctx.task.continue();
|
||||
});
|
||||
+2
-2
@@ -40,7 +40,7 @@ gopeed.events.onError(async function (ctx) {
|
||||
return;
|
||||
}
|
||||
|
||||
req.labels.recovered = "true";
|
||||
req.url = gopeed.runtime.blob.createObjectURL(new Blob(["ok\n"], { type: "text/plain" }));
|
||||
req.putLabel("recovered", "true");
|
||||
ctx.task.setUrl(gopeed.runtime.blob.createObjectURL(new Blob(["ok\n"], { type: "text/plain" })));
|
||||
ctx.task.continue();
|
||||
});
|
||||
+4
-5
@@ -41,18 +41,17 @@ gopeed.events.onError(async function (ctx) {
|
||||
if (!req || !req.rawUrl || !req.url || !req.url.includes('/__blob/')) {
|
||||
return;
|
||||
}
|
||||
req.labels = req.labels || {};
|
||||
if (req.labels.rebuilt === 'true') {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
req.url = createRangeBlobUrl(req.rawUrl);
|
||||
req.labels.started = 'true';
|
||||
req.labels.rebuilt = 'true';
|
||||
ctx.task.setUrl(createRangeBlobUrl(req.rawUrl));
|
||||
req.putLabel('started', 'true');
|
||||
req.putLabel('rebuilt', 'true');
|
||||
ctx.task.continue();
|
||||
} catch (error) {
|
||||
req.labels.rebuildError = String(error);
|
||||
req.putLabel('rebuildError', String(error));
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
+1
-2
@@ -1,7 +1,6 @@
|
||||
gopeed.events.onError(async function (ctx) {
|
||||
gopeed.logger.info("url", ctx.task.meta.req.url);
|
||||
gopeed.logger.info("error", ctx.error);
|
||||
ctx.task.meta.req.url = "https://github.com";
|
||||
ctx.task.setUrl("https://github.com");
|
||||
ctx.task.continue();
|
||||
});
|
||||
|
||||
+2
-3
@@ -1,6 +1,5 @@
|
||||
gopeed.events.onStart(async function (ctx) {
|
||||
gopeed.logger.info("url", ctx.task.meta.req.url);
|
||||
ctx.task.meta.req.url = "https://github.com";
|
||||
ctx.task.meta.req.labels['modified'] = 'true';
|
||||
ctx.task.setUrl("https://github.com");
|
||||
ctx.task.meta.req.putLabel('modified', 'true');
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user