MCPcopy Index your code
hub / github.com/scriptscat/scriptcat / migrateToChromeStorage

Function migrateToChromeStorage

src/app/migrate.ts:15–204  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13
14// 迁移数据到chrome.storage
15export function migrateToChromeStorage() {
16 // 默认使用的事务,这里加个延时,用db.open()打开数据库后,再执行
17 setTimeout(async () => {
18 try {
19 // 迁移脚本
20 const scripts = await db.table("scripts").toArray();
21 const scriptDAO = new ScriptDAO();
22 const scriptCodeDAO = new ScriptCodeDAO();
23 console.log("开始迁移脚本数据", scripts.length);
24 await Promise.all(
25 // 不处理 Promise.reject ?
26 scripts.map(async (script: ScriptAndCode) => {
27 const {
28 uuid,
29 name,
30 namespace,
31 author,
32 originDomain,
33 subscribeUrl,
34 type,
35 sort,
36 status,
37 runStatus,
38 metadata,
39 createtime,
40 checktime,
41 code,
42 checkUpdateUrl,
43 downloadUrl,
44 selfMetadata,
45 config,
46 error,
47 updatetime,
48 lastruntime,
49 nextruntime,
50 } = script;
51 const s = await scriptDAO.save({
52 uuid,
53 name,
54 namespace,
55 author,
56 originDomain,
57 origin,
58 checkUpdateUrl,
59 downloadUrl,
60 metadata,
61 selfMetadata,
62 subscribeUrl,
63 config,
64 type,
65 status,
66 sort,
67 runStatus,
68 error,
69 createtime,
70 updatetime,
71 checktime,
72 lastruntime,

Callers 2

ToolsFunction · 0.90
renameFieldFunction · 0.85

Calls 13

saveMethod · 0.95
saveMethod · 0.95
saveMethod · 0.95
saveMethod · 0.95
saveMethod · 0.95
getStorageNameFunction · 0.90
logMethod · 0.80
keysMethod · 0.80
errorMethod · 0.80
hasMethod · 0.65
setMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected