Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean up non existing profiles sync state #170030

Merged
merged 1 commit into from Dec 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -27,9 +27,30 @@ export class UserDataSyncBackupStoreService extends Disposable implements IUserD
@IUserDataProfilesService private readonly userDataProfilesService: IUserDataProfilesService,
) {
super();
this.cleanUp();
}

private async cleanUp(): Promise<void> {
for (const profile of this.userDataProfilesService.profiles) {
for (const resource of ALL_SYNC_RESOURCES) {
this.cleanUpBackup(this.getResourceBackupHome(profile, resource));
try {
await this.cleanUpBackup(this.getResourceBackupHome(profile, resource));
} catch (error) {
this.logService.error(error);
}
}
}
const stat = await this.fileService.resolve(this.environmentService.userDataSyncHome);
if (stat.children) {
for (const child of stat.children) {
if (child.isDirectory && !this.userDataProfilesService.profiles.some(profile => profile.id === child.name)) {
try {
this.logService.info('Deleting non existing profile from backup', child.resource.path);
await this.fileService.del(child.resource, { recursive: true });
} catch (error) {
this.logService.error(error);
}
}
}
}
}
Expand Down