mirror of
https://github.com/usebruno/bruno.git
synced 2024-12-12 09:40:50 +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 {
|
try {
|
||||||
const dirPath = path.join(collectionLocation, collectionFolderName);
|
const dirPath = path.join(collectionLocation, collectionFolderName);
|
||||||
if (fs.existsSync(dirPath)) {
|
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)) {
|
if (!isValidPathname(dirPath)) {
|
||||||
throw new Error(`collection: invalid pathname - ${dir}`);
|
throw new Error(`collection: invalid pathname - ${dir}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
await createDirectory(dirPath);
|
if (!fs.existsSync(dirPath)) {
|
||||||
|
await createDirectory(dirPath);
|
||||||
|
}
|
||||||
|
|
||||||
const uid = generateUidBasedOnHash(dirPath);
|
const uid = generateUidBasedOnHash(dirPath);
|
||||||
const brunoConfig = {
|
const brunoConfig = {
|
||||||
|
Loading…
Reference in New Issue
Block a user