Skip to content

Commit

Permalink
fix: check whether it is a bot project folder while opening (microsof…
Browse files Browse the repository at this point in the history
…t#4071)

Co-authored-by: zeye <zeye@microsoft.com>
Co-authored-by: Andy Brown <asbrown002@gmail.com>
  • Loading branch information
3 people committed Sep 14, 2020
1 parent 9020047 commit 1d53d75
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Composer/packages/server/src/services/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ export class BotProjectService {
throw new Error(`file ${locationRef.path} does not exist`);
}

if (!(await StorageService.checkIsBotFolder(locationRef.storageId, locationRef.path, user))) {
throw new Error(`${locationRef.path} is not a bot project folder`);
}

for (const key in BotProjectService.projectLocationMap) {
if (BotProjectService.projectLocationMap[key] === locationRef.path) {
// TODO: this should probably move to getProjectById
Expand Down
5 changes: 5 additions & 0 deletions Composer/packages/server/src/services/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ class StorageService {
}
};

public checkIsBotFolder = async (storageId: string, path: string, user?: UserIdentity) => {
const storageClient = this.getStorageClient(storageId, user);
return await this.isBotFolder(storageClient, path);
};

private ensureDefaultBotFoldersExist = () => {
this.storageConnections.forEach((s) => {
this.createFolderRecurively(s.defaultPath);
Expand Down

0 comments on commit 1d53d75

Please sign in to comment.