Missing temporary file deletion after using (MissingTemporaryFileDeletion)¶
Type | Scope | Severity | Activated by default |
Minutes to fix |
Tags |
---|---|---|---|---|---|
Error |
BSL OS |
Major |
Yes |
5 |
badpractice standard |
Parameters¶
Name | Type | Description | Default value |
---|---|---|---|
searchDeleteFileMethod |
String |
Keywords to search for delete/move files methods |
УдалитьФайлы|DeleteFiles|НачатьУдалениеФайлов|BeginDeletingFiles|ПереместитьФайл|MoveFile |
Description¶
After you finished working with temporary file or folder, you need to delete it yourself. You should not rely on automatic deletion of files and folders before platform start. This can cause temp folder free space shortage.
Examples¶
Incorrect:
TempFileName = GetTempFileName("xml");
Data.Write(TempFileName);
// Not delete temporary file
Correct:
TempFileName = GetTempFileName("xml");
Data.Write(TempFileName);
// Work with file
...
// Delete temporary file
Try
DeleteFiles(TempFileName);
Catch
WriteLogEvent(НСтр("ru = 'My subsystem.Action'"), EventLogLevel.Error, , , DetailErrorDescription(ErrorInfo()));
EndTry;
Nuances¶
Diagnostics determines the correctness of working with temporary files by the presence of methods for deleting or moving.
If the applied solution uses its own method of removing/moving over the platform one, then it is worth specifying it in the diagnostic parameter, adding it after |
. Diagnostics understands both global methods and those located in common modules or manager modules.
The following is an examples of a settings
- The global method
MyFileDeletion
in theGlobalServer
module in the parameter is specified asMyFileDeletion
- Method
MyFileDeletion
in the common moduleFilesClientServer
in the parameter is specified asFilesClientServer.MyFileDelete
- Method
MyFileOperations
in the module of the catalog managerFileOperations
in the parameter is specified asCatalogs.FileOperations.MyFileOperations
and so on.
Sources¶
Snippets¶
Diagnostic ignorance in code¶
// BSLLS:MissingTemporaryFileDeletion-off
// BSLLS:MissingTemporaryFileDeletion-on
Parameter for config¶
"MissingTemporaryFileDeletion": {
"searchDeleteFileMethod": "УдалитьФайлы|DeleteFiles|НачатьУдалениеФайлов|BeginDeletingFiles|ПереместитьФайл|MoveFile"
}