38
};
39
}
41
>
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
42
>
// NOTE: DO NOT CHANGE. IDENTIFIERS HAVE TO REMAIN STABLE
43
>
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
44
>
45
>
export function getSingleFolderWorkspaceIdentifier(folderUri: URI): ISingleFolderWorkspaceIdentifier | undefined;
46
>
export function getSingleFolderWorkspaceIdentifier(folderUri: URI, folderStat: Stats): ISingleFolderWorkspaceIdentifier;
47
>
export function getSingleFolderWorkspaceIdentifier(folderUri: URI, folderStat?: Stats): ISingleFolderWorkspaceIdentifier | undefined {
48
>
49
>
function getFolderId(): string | undefined {
50
>
51
>
// Remote: produce a hash from the entire URI
52
>
if (folderUri.scheme !== Schemas.file) {
53
>
return createHash('md5').update(folderUri.toString()).digest('hex'); // CodeQL [SM04514] Using MD5 to convert a file path to a fixed length
54
>
}
55
>
56
>
// Local: we use the ctime as extra salt to the
57
>
// identifier so that folders getting recreated
58
>
// result in a different identifier. However, if
59
>
// the stat is not provided we return `undefined`
60
>
// to ensure identifiers are stable for the given
61
>
// URI.
62
>
63
>
if (!folderStat) {
64
return undefined;
65
}
67
>
let ctime: number | undefined;
68
>
if (isLinux) {
69
>
ctime = folderStat.ino; // Linux: birthtime is ctime, so we cannot use it! We use the ino instead!
70
>
} else if (isMacintosh) {
71
ctime = folderStat.birthtime.getTime(); // macOS: birthtime is fine to use as is
72
} else if (isWindows) {