Record information about which files are wiped (#1997)

This commit is contained in:
Noah Gilson 2024-10-22 11:43:02 -07:00 коммит произвёл GitHub
Родитель 2ff7c2ac4d
Коммит a2e6a5c385
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
2 изменённых файлов: 12 добавлений и 0 удалений

Просмотреть файл

@ -763,6 +763,14 @@ export class DuplicateInstallDetected extends DotnetCustomMessageEvent {
public readonly eventName = 'DuplicateInstallDetected';
}
export class EmptyDirectoryToWipe extends DotnetCustomMessageEvent {
public readonly eventName = 'EmptyDirectoryToWipe';
}
export class FileToWipe extends DotnetCustomMessageEvent {
public readonly eventName = 'FileToWipe';
}
export class TriedToExitMasterSudoProcess extends DotnetCustomMessageEvent {
public readonly eventName = 'TriedToExitMasterSudoProcess';
}

Просмотреть файл

@ -19,6 +19,8 @@ import { DotnetCommandFallbackArchitectureEvent,
DotnetLockAttemptingAcquireEvent,
DotnetLockErrorEvent,
DotnetLockReleasedEvent,
EmptyDirectoryToWipe,
FileToWipe,
SuppressedAcquisitionError
} from '../EventStream/EventStreamEvents';
@ -105,6 +107,7 @@ export class FileUtilities extends IFileUtilities
{
if(!fs.existsSync(directoryToWipe))
{
eventStream?.post(new EmptyDirectoryToWipe(`The directory ${directoryToWipe} did not exist, so it was not wiped.`))
return;
}
@ -113,6 +116,7 @@ export class FileUtilities extends IFileUtilities
{
try
{
eventStream?.post(new FileToWipe(`The file ${f} is being deleted.`))
if(!fileExtensionsToDelete || path.extname(f).toLocaleLowerCase() in fileExtensionsToDelete)
fs.rmSync(path.join(directoryToWipe, f));
}