MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / storeImage

Function storeImage

source code/utils/imageStore.ts:56–81  ·  view source on GitHub ↗
(
  content: PastedContent,
)

Source from the content-addressed store, hash-verified

54 * Store an image from pastedContents to disk.
55 */
56export async function storeImage(
57 content: PastedContent,
58): Promise<string | null> {
59 if (content.type !== 'image') {
60 return null
61 }
62
63 try {
64 await ensureImageStoreDir()
65 const imagePath = getImagePath(content.id, content.mediaType || 'image/png')
66 const fh = await open(imagePath, 'w', 0o600)
67 try {
68 await fh.writeFile(content.content, { encoding: 'base64' })
69 await fh.datasync()
70 } finally {
71 await fh.close()
72 }
73 evictOldestIfAtCap()
74 storedImagePaths.set(content.id, imagePath)
75 logForDebugging(`Stored image ${content.id} to ${imagePath}`)
76 return imagePath
77 } catch (error) {
78 logForDebugging(`Failed to store image: ${error}`)
79 return null
80 }
81}
82
83/**
84 * Store all images from pastedContents to disk.

Callers 4

onImagePasteFunction · 0.85
onImagePasteFunction · 0.85
storeImagesFunction · 0.85

Calls 7

ensureImageStoreDirFunction · 0.85
getImagePathFunction · 0.85
openFunction · 0.85
evictOldestIfAtCapFunction · 0.85
logForDebuggingFunction · 0.85
setMethod · 0.80
closeMethod · 0.45

Tested by

no test coverage detected