fix: collection zip import for default workspace (#7108)

* fix: collection zip import for default workspace

* fixes
This commit is contained in:
naman-bruno
2026-02-11 19:12:08 +05:30
committed by GitHub
parent ccac391848
commit 2d8c767b90

View File

@@ -2138,18 +2138,20 @@ const registerRendererEventHandlers = (mainWindow, watcher) => {
}
let collectionName = 'Imported Collection';
let brunoConfig = { name: collectionName, version: '1', type: 'collection', ignore: ['node_modules', '.git'] };
if (fs.existsSync(openCollectionYmlPath)) {
try {
const content = fs.readFileSync(openCollectionYmlPath, 'utf8');
const { brunoConfig } = parseCollection(content, { format: 'yml' });
collectionName = brunoConfig?.name || collectionName;
const parsed = parseCollection(content, { format: 'yml' });
brunoConfig = parsed.brunoConfig || brunoConfig;
collectionName = brunoConfig.name || collectionName;
} catch (e) {
console.error(`Error parsing opencollection.yml at ${openCollectionYmlPath}:`, e);
}
} else if (fs.existsSync(brunoJsonPath)) {
try {
const config = JSON.parse(fs.readFileSync(brunoJsonPath, 'utf8'));
collectionName = config.name || collectionName;
brunoConfig = JSON.parse(fs.readFileSync(brunoJsonPath, 'utf8'));
collectionName = brunoConfig.name || collectionName;
} catch (e) {
console.error(`Error parsing bruno.json at ${brunoJsonPath}:`, e);
}
@@ -2171,6 +2173,14 @@ const registerRendererEventHandlers = (mainWindow, watcher) => {
await fsExtra.remove(tempDir).catch(() => {});
}
const uid = generateUidBasedOnHash(finalCollectionPath);
const { size, filesCount } = await getCollectionStats(finalCollectionPath);
brunoConfig.size = size;
brunoConfig.filesCount = filesCount;
mainWindow.webContents.send('main:collection-opened', finalCollectionPath, uid, brunoConfig);
ipcMain.emit('main:collection-opened', mainWindow, finalCollectionPath, uid, brunoConfig);
return finalCollectionPath;
} catch (error) {
await fsExtra.remove(tempDir).catch(() => {});