Skip to content

Commit 654fa6b

Browse files
committed
Add some more logs
1 parent 1e16d01 commit 654fa6b

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

src/sync-manager.ts

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ export default class SyncManager {
197197
const reader = new ZipReader(new BlobReader(zipBlob));
198198
const entries = await reader.getEntries();
199199

200+
await this.logger.info("Extracting files from ZIP", {
201+
length: entries.length,
202+
});
203+
200204
await Promise.all(
201205
entries.map(async (entry: Entry) => {
202206
// All repo ZIPs contain a root directory that contains all the content
@@ -218,11 +222,18 @@ export default class SyncManager {
218222
targetPath.startsWith(this.vault.configDir) &&
219223
targetPath !== `${this.vault.configDir}/${MANIFEST_FILE_NAME}`
220224
) {
225+
await this.logger.info("Skipped config", { targetPath });
221226
return;
222227
}
223228

224229
if (entry.directory) {
225-
await this.vault.adapter.mkdir(normalizePath(targetPath));
230+
const normalizedPath = normalizePath(targetPath);
231+
await this.vault.adapter.mkdir(normalizedPath);
232+
await this.logger.info("Created directory", {
233+
normalizedPath,
234+
});
235+
return;
236+
}
226237

227238
if (targetPath.split("/").last()?.startsWith(".")) {
228239
// We must skip hidden files as that creates issues with syncing.
@@ -236,12 +247,23 @@ export default class SyncManager {
236247
const data = await writer.getData();
237248
const dir = targetPath.split("/").splice(0, -1).join("/");
238249
if (dir !== "") {
239-
await this.vault.adapter.mkdir(normalizePath(dir));
250+
const normalizedDir = normalizePath(dir);
251+
await this.vault.adapter.mkdir(normalizedDir);
252+
await this.logger.info("Created directory", {
253+
normalizedDir,
254+
});
240255
}
241-
await this.vault.adapter.writeBinary(normalizePath(targetPath), data);
256+
257+
const normalizedPath = normalizePath(targetPath);
258+
await this.vault.adapter.writeBinary(normalizedPath, data);
259+
await this.logger.info("Written file", {
260+
normalizedPath,
261+
});
242262
}),
243263
);
244264

265+
await this.logger.info("Extracted zip");
266+
245267
const newTreeFiles = Object.keys(files)
246268
.map((filePath: string) => ({
247269
path: files[filePath].path,
@@ -782,6 +804,7 @@ export default class SyncManager {
782804
retry: true,
783805
maxRetries: 3,
784806
});
807+
await this.logger.info("Created blob", filePath);
785808
treeFiles[filePath].sha = sha;
786809
// Can't have both sha and content set, so we delete it
787810
delete treeFiles[filePath].content;

0 commit comments

Comments
 (0)