fix: check for valid connection (#428)
* fix: check for valid connection * refactor: remove unused import
This commit is contained in:
Родитель
162a7660cf
Коммит
9cb6c5830a
|
@ -63,8 +63,13 @@ export class AzureBlobStorage implements IStorageProvider {
|
|||
|
||||
public async isValidProjectConnection() {
|
||||
try {
|
||||
await new ServiceURL(this.options.sas, StorageURL.newPipeline(this.getCredential())).getAccountInfo(Aborter.none);
|
||||
return (true);
|
||||
return await new ServiceURL(this.options.sas, StorageURL.newPipeline(this.getCredential())).getAccountInfo(Aborter.timeout(5000))
|
||||
.then(() => {
|
||||
return true;
|
||||
})
|
||||
.catch(() => {
|
||||
return false;
|
||||
})
|
||||
} catch {
|
||||
return (false);
|
||||
}
|
||||
|
|
|
@ -178,7 +178,7 @@ export default class HomePage extends React.Component<IHomePageProps, IHomePageS
|
|||
let projectStr: string;
|
||||
try {
|
||||
const projectService = new ProjectService();
|
||||
if (!(await projectService.isValidProjectConnection(project))) {
|
||||
if (!(await projectService.isValidProjectConnection(decryptedProject))) {
|
||||
return;
|
||||
}
|
||||
projectStr = await storageProvider.readText(
|
||||
|
|
|
@ -161,7 +161,12 @@ export default class ProjectService implements IProjectService {
|
|||
|
||||
public async isValidProjectConnection(project: IProject): Promise<boolean> {
|
||||
const storageProvider = StorageProviderFactory.createFromConnection(project.sourceConnection);
|
||||
const isValid = await storageProvider.isValidProjectConnection();
|
||||
let isValid;
|
||||
try {
|
||||
isValid = await storageProvider.isValidProjectConnection();
|
||||
} catch {
|
||||
isValid = false;
|
||||
}
|
||||
if (!isValid) {
|
||||
if (project.sourceConnection.providerType === "localFileSystemProxy") {
|
||||
await toast.error(interpolate(strings.connections.providers.local.invalidFolderMessage, {project}));
|
||||
|
|
Загрузка…
Ссылка в новой задаче