MCPcopy Create free account
hub / github.com/MemeTray/MemeTray / processFiles

Function processFiles

tools/duplicate-detector/script.js:91–140  ·  view source on GitHub ↗
(files)

Source from the content-addressed store, hash-verified

89}
90
91async function processFiles(files) {
92 const progressContainer = document.getElementById('progressContainer');
93 const progressText = document.getElementById('progressText');
94 const progressPercent = document.getElementById('progressPercent');
95 const progressFill = document.getElementById('progressFill');
96 const batchActions = document.getElementById('batchActions');
97 const statsContainer = document.getElementById('statsContainer');
98
99 progressContainer.style.display = 'block';
100 const totalFiles = files.length;
101 let processedCount = 0;
102
103 for (const fileObj of files) {
104 try {
105 // Compute the content hash
106 const hash = await calculatePixelHash(fileObj.file);
107
108 // Create a preview URL
109 const url = URL.createObjectURL(fileObj.file);
110
111 allFiles.push({
112 id: fileIdCounter++,
113 name: fileObj.file.name,
114 path: fileObj.path,
115 size: fileObj.file.size,
116 hash: hash,
117 url: url,
118 file: fileObj.file
119 });
120
121 processedCount++;
122 const percent = Math.round((processedCount / totalFiles) * 100);
123 progressText.textContent = `Analyzing: ${processedCount} / ${totalFiles}`;
124 progressPercent.textContent = `${percent}%`;
125 progressFill.style.width = `${percent}%`;
126 } catch (error) {
127 console.error('Error processing file:', fileObj.file.name, error);
128 processedCount++;
129 }
130 }
131
132 progressContainer.style.display = 'none';
133 batchActions.style.display = 'flex';
134 statsContainer.style.display = 'grid';
135
136 // Reset the file input so the same folder can be selected again
137 document.getElementById('fileInput').value = '';
138
139 analyzeAndDisplay();
140}
141
142function analyzeAndDisplay() {
143 const hashMap = new Map();

Callers

nothing calls this directly

Calls 2

calculatePixelHashFunction · 0.85
analyzeAndDisplayFunction · 0.85

Tested by

no test coverage detected