MCPcopy Create free account
hub / github.com/Make-md/makemd / parseCache

Method parseCache

src/adapters/image/imageAdapter.ts:54–89  ·  view source on GitHub ↗
(file: AFile, refresh: boolean)

Source from the content-addressed store, hash-verified

52}
53public loadFile: (file: AFile) => Promise<void>;
54 public async parseCache (file: AFile, refresh: boolean) {
55
56
57 if (!file) return;
58 const thumbnailPath = `${this.cacheDirectory}/${hashCode(file.path)}.${file.extension}`;
59 let thumbnail = file.path
60 if (this.plugin.superstate.settings.imageThumbnails) {
61 if (!(await this.middleware.fileExists(thumbnailPath)))
62 {
63 if (!Platform.isMobile) {
64 const thumbnailResult = await this.generateThumbnail(file, thumbnailPath);
65 if (thumbnailResult) {
66 thumbnail = thumbnailPath
67 }
68 }
69 } else {
70 thumbnail = thumbnailPath
71 }
72 }
73 const label = this.middleware.getFileCache(file.path)?.label
74 const updatedCache = {
75 subtype: "image",
76 label: {
77 name: file.name,
78 sticker: label?.sticker.length > 0 ? label.sticker : "ui//mk-make-image",
79 color: label?.color,
80 thumbnail: thumbnail,
81 cover: thumbnail,
82 },
83 preview: {
84 thumbnail: thumbnail,
85 }
86 }
87 this.cache.set(file.path, updatedCache);
88 this.middleware.updateFileCache(file.path, this.cache.get(file.path), refresh);
89 }
90
91 public cacheTypes (file: AFile) { return [] as Array<keyof ImageTypeCache>}
92 public contentTypes (file: AFile) { return [] as Array<keyof ImageTypeContent>}

Callers

nothing calls this directly

Calls 7

generateThumbnailMethod · 0.95
hashCodeFunction · 0.90
fileExistsMethod · 0.45
getFileCacheMethod · 0.45
setMethod · 0.45
updateFileCacheMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected