MCPcopy Create free account
hub / github.com/chhoumann/quickadd / encodeAssets

Function encodeAssets

src/services/packageExportService.ts:152–187  ·  view source on GitHub ↗
(
	app: App,
	descriptors: AssetDescriptor[],
)

Source from the content-addressed store, hash-verified

150}
151
152async function encodeAssets(
153 app: App,
154 descriptors: AssetDescriptor[],
155): Promise<EncodedAssets> {
156 const encodedAssets: QuickAddPackageAsset[] = [];
157 const missingAssets: MissingAsset[] = [];
158
159 for (const { path, kind } of descriptors) {
160 try {
161 const exists = await app.vault.adapter.exists(path);
162 if (!exists) {
163 missingAssets.push({ path, kind });
164 log.logWarning(`QuickAdd export skipped missing ${kind}: ${path}`);
165 continue;
166 }
167
168 const content = await app.vault.adapter.read(path);
169
170 encodedAssets.push({
171 kind,
172 originalPath: path,
173 contentEncoding: "base64",
174 content: encodeToBase64(content),
175 });
176 } catch (error) {
177 missingAssets.push({ path, kind });
178 log.logWarning(
179 `QuickAdd export failed to read ${kind} '${path}': ${
180 (error as Error)?.message ?? error
181 }`,
182 );
183 }
184 }
185
186 return { encodedAssets, missingAssets };
187}
188
189function buildSecretOptionNamesByPath(
190 assets: QuickAddPackageAsset[],

Callers 1

buildPackageFunction · 0.85

Calls 3

encodeToBase64Function · 0.90
pushMethod · 0.80
logWarningMethod · 0.65

Tested by

no test coverage detected