mirror of
https://github.com/usebruno/bruno.git
synced 2024-12-11 17:20:39 +01:00
fix: can't create collection on empty directory (#3256)
This commit is contained in:
parent
4ea141fd73
commit
9aa84a259c
@ -65,14 +65,20 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
|
||||
try {
|
||||
const dirPath = path.join(collectionLocation, collectionFolderName);
|
||||
if (fs.existsSync(dirPath)) {
|
||||
throw new Error(`collection: ${dirPath} already exists`);
|
||||
const files = fs.readdirSync(dirPath);
|
||||
|
||||
if (files.length > 0) {
|
||||
throw new Error(`collection: ${dirPath} already exists and is not empty`);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isValidPathname(dirPath)) {
|
||||
throw new Error(`collection: invalid pathname - ${dir}`);
|
||||
}
|
||||
|
||||
if (!fs.existsSync(dirPath)) {
|
||||
await createDirectory(dirPath);
|
||||
}
|
||||
|
||||
const uid = generateUidBasedOnHash(dirPath);
|
||||
const brunoConfig = {
|
||||
|
Loading…
Reference in New Issue
Block a user