Missing temporary file deletion after using (MissingTemporaryFileDeletion)¶
| Type | Scope | Severity | Activated by default |
Minutes to fix |
Tags |
|---|---|---|---|---|---|
Error |
BSLOS |
Major |
Yes |
5 |
badpracticestandard |
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
MyFileDeletionin theGlobalServermodule in the parameter is specified asMyFileDeletion - Method
MyFileDeletionin the common moduleFilesClientServerin the parameter is specified asFilesClientServer.MyFileDelete - Method
MyFileOperationsin the module of the catalog managerFileOperationsin 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"
}