mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-16 01:25:36 -05:00
Don't allow duplicate file/folder entries to be added to sql projects (#15104)
* don't allow adding the same file or folder to the sqlproj if it has already been added * add a couple more checks in test * toLowerCase when comparing
This commit is contained in:
@@ -266,6 +266,11 @@ export class Project {
|
||||
public async addFolderItem(relativeFolderPath: string): Promise<FileProjectEntry> {
|
||||
const absoluteFolderPath = path.join(this.projectFolderPath, relativeFolderPath);
|
||||
|
||||
// check if folder already has been added to sqlproj
|
||||
if (this.files.find(f => f.relativePath.toLowerCase() === relativeFolderPath.toLowerCase())) {
|
||||
throw new Error(constants.folderAlreadyAddedToProject((relativeFolderPath)));
|
||||
}
|
||||
|
||||
//If folder doesn't exist, create it
|
||||
let exists = await utils.exists(absoluteFolderPath);
|
||||
if (!exists) {
|
||||
@@ -292,6 +297,11 @@ export class Project {
|
||||
throw new Error(constants.fileAlreadyExists(path.parse(absoluteFilePath).name));
|
||||
}
|
||||
|
||||
// check if file already has been added to sqlproj
|
||||
if (this.files.find(f => f.relativePath.toLowerCase() === relativeFilePath.toLowerCase())) {
|
||||
throw new Error(constants.fileAlreadyAddedToProject((relativeFilePath)));
|
||||
}
|
||||
|
||||
// create the file if contents were passed in
|
||||
if (contents) {
|
||||
await fs.mkdir(path.dirname(absoluteFilePath), { recursive: true });
|
||||
|
||||
Reference in New Issue
Block a user