Skip to content

Commit f2bb105

Browse files
committed
1 parent d67d53d commit f2bb105

1 file changed

Lines changed: 7 additions & 20 deletions

File tree

src/vs/platform/extensionManagement/node/extensionManagementService.ts

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,6 @@ interface InstallableExtension {
101101

102102
export class ExtensionManagementService extends Disposable implements IExtensionManagementService {
103103

104-
private static readonly RENAME_RETRY_TIME = 5 * 1000;
105-
106104
_serviceBrand: any;
107105

108106
private extensionsPath: string;
@@ -429,7 +427,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
429427
}
430428

431429
private completeInstall(id: string, extractPath: string): TPromise<void> {
432-
return this.renameWithRetry(id, extractPath)
430+
return this.rename(id, extractPath, Date.now() + (5 * 1000) /* Retry for 5 seconds */)
433431
.then(
434432
() => this.logService.info('Installation compelted.', id),
435433
e => {
@@ -439,23 +437,12 @@ export class ExtensionManagementService extends Disposable implements IExtension
439437
});
440438
}
441439

442-
private renameWithRetry(id: string, extractPath: string): TPromise<void> {
443-
const retry = (task: () => TPromise<any>, shouldRetry: (err: any) => boolean) => {
444-
return task().then(
445-
null,
446-
err => {
447-
if (shouldRetry(err)) {
448-
return retry(task, shouldRetry);
449-
} else {
450-
throw err;
451-
}
452-
});
453-
};
454-
455-
const retryUntil = Date.now() + ExtensionManagementService.RENAME_RETRY_TIME;
456-
return retry(
457-
() => pfs.rename(extractPath, path.join(this.extensionsPath, id)),
458-
err => isWindows && err && err.code === 'EPERM' && Date.now() < retryUntil);
440+
private rename(id: string, extractPath: string, retryUntil: number): TPromise<void> {
441+
return pfs.rename(extractPath, path.join(this.extensionsPath, id))
442+
.then(null, error =>
443+
isWindows && error && error.code === 'EPERM' && Date.now() < retryUntil
444+
? this.rename(id, extractPath, retryUntil)
445+
: TPromise.wrapError(error));
459446
}
460447

461448
private rollback(extensions: IGalleryExtension[]): TPromise<void> {

0 commit comments

Comments
 (0)