mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-27 14:44:07 +00:00
fix: collection zip import for default workspace (#7108)
* fix: collection zip import for default workspace * fixes
This commit is contained in:
@@ -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(() => {});
|
||||
|
||||
Reference in New Issue
Block a user