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

Method transferSyncToLocal

src/pkg/config/config.ts:131–145  ·  view source on GitHub ↗
(
    key: SystemConfigKey,
    defaultValue: WithAsyncValue<Exclude<T, undefined>>
  )

Source from the content-addressed store, hash-verified

129 }
130
131 private async transferSyncToLocal<T>(
132 key: SystemConfigKey,
133 defaultValue: WithAsyncValue<Exclude<T, undefined>>
134 ): Promise<T> {
135 const syncVal = await this.syncStorage.get(key);
136 if (syncVal === undefined) {
137 this.cache.set(key, undefined);
138 return this.resolveDefault<T>(defaultValue);
139 }
140 // 迁移到 local storage 并从 sync 中删除
141 await this.syncStorage.remove(key); // 先删除
142 await this.localStorage.set(key, syncVal); // 删除成功后储回本地
143 this.cache.set(key, syncVal);
144 return syncVal as T;
145 }
146
147 private _get<T extends string | number | boolean | object>(
148 key: SystemConfigKey,

Callers 1

_getMethod · 0.95

Calls 4

resolveDefaultMethod · 0.95
getMethod · 0.65
setMethod · 0.65
removeMethod · 0.65

Tested by

no test coverage detected