Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected async buildWorkspaceId(workspace: FileStat, roots: FileStat[]): Promise {
const homeDir = await this.getUserHomeDir();
const untitledWorkspace = getTemporaryWorkspaceFileUri(new URI(homeDir));
if (untitledWorkspace.toString() === workspace.uri) {
// if workspace is temporary
// then let create a storage path for each set of workspace roots
const rootsStr = roots.map(root => root.uri).sort().join(',');
return crypto.createHash('md5').update(rootsStr).digest('hex');
} else {
const uri = new URI(workspace.uri);
let displayName = uri.displayName;
if ((!workspace || !workspace.isDirectory) && (displayName.endsWith(`.${THEIA_EXT}`) || displayName.endsWith(`.${VSCODE_EXT}`))) {
displayName = displayName.slice(0, displayName.lastIndexOf('.'));
}
return crypto.createHash('md5').update(uri.toString()).digest('hex');
}