Skip to content

Commit cef7237

Browse files
Directory PrivateTempStorage should only be created when necessary (#906)
* Directory PrivateTempStorage should only be created when necessary * Separate ProcedureTest.cs into a different project to ensure that PrivateTempStorage is not initialized.
1 parent a48f991 commit cef7237

File tree

6 files changed

+291
-2
lines changed

6 files changed

+291
-2
lines changed

dotnet/DotNetStandardClasses.sln

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,11 @@ EndProject
250250
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotNetCoreAttackMitigationTest", "test\DotNetCoreAttackMitigationTest\DotNetCoreAttackMitigationTest.csproj", "{2D615969-53E2-4B77-9A9A-75C33865CF76}"
251251
EndProject
252252
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotNetCoreChunkedTest", "test\DotNetCoreChunkedTest\DotNetCoreChunkedTest.csproj", "{5D2B1299-479F-430A-8D72-34D44FB299FD}"
253+
EndProject
253254
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotNetPDFUnitTest", "test\DotNetPdfTest\DotNetPDFUnitTest.csproj", "{0FCFB078-5584-469F-92CC-61B0A6216D0D}"
254255
EndProject
256+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotNetCoreCmdTest", "test\DotNetCoreCmdTest\DotNetCoreCmdTest.csproj", "{956402BD-AC8C-426E-961B-B77B3F3EDAEB}"
257+
EndProject
255258
Global
256259
GlobalSection(SolutionConfigurationPlatforms) = preSolution
257260
Debug|Any CPU = Debug|Any CPU
@@ -614,6 +617,10 @@ Global
614617
{0FCFB078-5584-469F-92CC-61B0A6216D0D}.Debug|Any CPU.Build.0 = Debug|Any CPU
615618
{0FCFB078-5584-469F-92CC-61B0A6216D0D}.Release|Any CPU.ActiveCfg = Release|Any CPU
616619
{0FCFB078-5584-469F-92CC-61B0A6216D0D}.Release|Any CPU.Build.0 = Release|Any CPU
620+
{956402BD-AC8C-426E-961B-B77B3F3EDAEB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
621+
{956402BD-AC8C-426E-961B-B77B3F3EDAEB}.Debug|Any CPU.Build.0 = Debug|Any CPU
622+
{956402BD-AC8C-426E-961B-B77B3F3EDAEB}.Release|Any CPU.ActiveCfg = Release|Any CPU
623+
{956402BD-AC8C-426E-961B-B77B3F3EDAEB}.Release|Any CPU.Build.0 = Release|Any CPU
617624
EndGlobalSection
618625
GlobalSection(SolutionProperties) = preSolution
619626
HideSolutionNode = FALSE
@@ -735,6 +742,7 @@ Global
735742
{2D615969-53E2-4B77-9A9A-75C33865CF76} = {1D6F1776-FF4B-46C2-9B3D-BC46CCF049DC}
736743
{5D2B1299-479F-430A-8D72-34D44FB299FD} = {1D6F1776-FF4B-46C2-9B3D-BC46CCF049DC}
737744
{0FCFB078-5584-469F-92CC-61B0A6216D0D} = {1D6F1776-FF4B-46C2-9B3D-BC46CCF049DC}
745+
{956402BD-AC8C-426E-961B-B77B3F3EDAEB} = {1D6F1776-FF4B-46C2-9B3D-BC46CCF049DC}
738746
EndGlobalSection
739747
GlobalSection(ExtensibilityGlobals) = postSolution
740748
SolutionGuid = {E18684C9-7D76-45CD-BF24-E3944B7F174C}

dotnet/src/dotnetframework/GxClasses/Data/GXDataADO.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,13 @@ public string DSVersion
11521152
}
11531153
public string BlobPath
11541154
{
1155-
get {return blobPath;}
1155+
get {
1156+
if (blobPath == null)
1157+
{
1158+
blobPath = Preferences.getBLOB_PATH();
1159+
}
1160+
return blobPath;
1161+
}
11561162
set {blobPath=value;}
11571163
}
11581164
public string MultimediaPath
@@ -2631,7 +2637,6 @@ private void Initialize(IGxDataRecord db, string id, int hnd, IGxContext context
26312637
if ( ! cfg)
26322638
connection.ConnectionString = connectionString;
26332639

2634-
connection.BlobPath = Preferences.getBLOB_PATH();
26352640
string strCache;
26362641
connection.Cache=((Config.GetValueOf("CACHING",out strCache) && strCache.Equals("1")) || CacheFactory.ForceHighestTimetoLive) && ! GxContext.isReorganization;
26372642
connection.DataStore = this;
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
using System;
2+
using System.IO;
3+
using GeneXus.Application;
4+
using GeneXus.Configuration;
5+
using GeneXus.Data;
6+
using GeneXus.Data.NTier;
7+
using GeneXus.Data.NTier.ADO;
8+
using GeneXus.Procedure;
9+
using UnitTesting;
10+
using Xunit;
11+
12+
namespace DotNetCoreUnitTest.Domain
13+
{
14+
public class ProcedureInitializationTest : FileSystemTest
15+
{
16+
[Fact]
17+
public void PublicTempStorageNotCreated()
18+
{
19+
bool isKey = Config.GetValueOf("CS_BLOB_PATH", out string blobPath);
20+
Assert.True(isKey);
21+
string path = Path.Combine(BaseDir, blobPath);
22+
aprocedure1 aprocedure1 = new aprocedure1();
23+
aprocedure1.execute();
24+
Assert.False(Directory.Exists(path), $"The directory {blobPath} should only be created when necessary.");
25+
26+
isKey = Config.GetValueOf("TMPMEDIA_DIR", out string tempMediaDir);
27+
Assert.True(isKey);
28+
path = Path.Combine(BaseDir, tempMediaDir);
29+
Assert.False(Directory.Exists(path), $"The directory {tempMediaDir} should only be created when necessary.");
30+
}
31+
}
32+
public class aprocedure1 : GXProcedure
33+
{
34+
35+
public int executeCmdLine(string[] args)
36+
{
37+
return ExecuteCmdLine(args); ;
38+
}
39+
40+
protected override int ExecuteCmdLine(string[] args)
41+
{
42+
execute();
43+
return GX.GXRuntime.ExitCode;
44+
}
45+
46+
public aprocedure1()
47+
{
48+
context = new GxContext();
49+
DataStoreUtil.LoadDataStores(context);
50+
IsMain = true;
51+
context.SetDefaultTheme("CmdLine", true);
52+
}
53+
54+
public aprocedure1(IGxContext context)
55+
{
56+
this.context = context;
57+
IsMain = false;
58+
}
59+
60+
public void execute()
61+
{
62+
initialize();
63+
try
64+
{
65+
ExecutePrivate();
66+
}
67+
catch (ReturnInErrorHandlerException)
68+
{
69+
this.cleanup();
70+
return;
71+
}
72+
}
73+
74+
public void executeSubmit()
75+
{
76+
SubmitImpl();
77+
}
78+
79+
protected override void ExecutePrivate()
80+
{
81+
/* GeneXus formulas */
82+
/* Output device settings */
83+
pr_default.close(0);
84+
this.cleanup();
85+
}
86+
87+
public override void cleanup()
88+
{
89+
CloseCursors();
90+
if (IsMain)
91+
{
92+
context.CloseConnections();
93+
}
94+
ExitApp();
95+
}
96+
97+
public override void initialize()
98+
{
99+
P000D2_A1GXM01_CtlName = new string[] { "" };
100+
pr_default = new DataStoreProvider(context, new aprocedure1__default(),
101+
new Object[][] {
102+
new Object[] {
103+
P000D2_A1GXM01_CtlName
104+
}
105+
}
106+
);
107+
/* GeneXus formulas. */
108+
}
109+
110+
private IDataStoreProvider pr_default;
111+
private string[] P000D2_A1GXM01_CtlName;
112+
}
113+
114+
public class aprocedure1__default : DataStoreHelperBase, IDataStoreHelper
115+
{
116+
public ICursor[] getCursors()
117+
{
118+
cursorDefinitions();
119+
return new Cursor[] {
120+
new ForEachCursor(def[0])
121+
};
122+
}
123+
124+
private static CursorDef[] def;
125+
private void cursorDefinitions()
126+
{
127+
if (def == null)
128+
{
129+
Object[] prmP000D2;
130+
prmP000D2 = new Object[] {
131+
};
132+
def = new CursorDef[] {
133+
new CursorDef("P000D2", "SELECT TOP 1 [GXM01_CtlName] FROM [GXM01] WHERE [GXM01_CtlName] = 'FCA010_DL_Name' ORDER BY [GXM01_CtlName] ",false, GxErrorMask.GX_NOMASK | GxErrorMask.GX_MASKLOOPLOCK, false, this,prmP000D2,1, GxCacheFrequency.OFF ,false,true )
134+
};
135+
}
136+
}
137+
138+
public void getResults(int cursor,
139+
IFieldGetter rslt,
140+
Object[] buf)
141+
{
142+
switch (cursor)
143+
{
144+
case 0:
145+
((string[])buf[0])[0] = rslt.getVarchar(1);
146+
return;
147+
}
148+
}
149+
150+
}
151+
152+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
4+
<NoWarn>CS8032;1701;1702;NU1701</NoWarn>
5+
<RollForward>Major</RollForward>
6+
</PropertyGroup>
7+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
8+
<DefineConstants>TRACE;NETCORE</DefineConstants>
9+
</PropertyGroup>
10+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
11+
<DefineConstants>DEBUG;TRACE;NETCORE</DefineConstants>
12+
</PropertyGroup>
13+
14+
15+
16+
<ItemGroup>
17+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
18+
<PackageReference Include="xunit" Version="2.4.1" />
19+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
20+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
21+
<PrivateAssets>all</PrivateAssets>
22+
</PackageReference>
23+
</ItemGroup>
24+
25+
<ItemGroup>
26+
<ProjectReference Include="..\..\src\dotnetcommon\GxEncrypt\GxEncrypt.csproj" />
27+
<ProjectReference Include="..\..\src\dotnetcore\GxClasses.Web\GxClasses.Web.csproj" />
28+
<ProjectReference Include="..\..\src\dotnetcore\GxClasses\GxClasses.csproj" />
29+
</ItemGroup>
30+
31+
<ItemGroup>
32+
<None Update="appsettings.json">
33+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
34+
</None>
35+
</ItemGroup>
36+
37+
38+
<ItemGroup>
39+
<Folder Include="Domain\" />
40+
</ItemGroup>
41+
42+
43+
</Project>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using GeneXus.Utils;
7+
8+
namespace UnitTesting
9+
{
10+
public class FileSystemTest
11+
{
12+
#pragma warning disable CA2211 // Non-constant fields should not be visible
13+
protected static string BaseDir = FileUtil.GetStartupDirectory();
14+
#pragma warning restore CA2211 // Non-constant fields should not be visible
15+
}
16+
17+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
"appSettings": {
3+
"AppMainNamespace": "GeneXus.Programs",
4+
"DataStore1": "Default",
5+
"DataStore-Count": "1",
6+
"DataStore-Default": "Default",
7+
"Connection-Default-DBMS": "sqlserver",
8+
"Connection-Default-Port": "",
9+
"Connection-Default-LockTimeout": "0",
10+
"Connection-Default-LockRetryCount": "10",
11+
"Connection-Default-IsolationLevel": "CR",
12+
"Connection-Default-Datasource": "",
13+
"Connection-Default-User": "",
14+
"Connection-Default-Password": "",
15+
"Connection-Default-DB": "",
16+
"Connection-Default-Schema": "",
17+
"Connection-Default-Opts": "",
18+
"Connection-Default-TrnInt": "1",
19+
"DateFormat": "MDY",
20+
"YearLimit": "1940",
21+
"TimeAmPmFormat": "12",
22+
"VER_STAMP": "20210602.093942",
23+
"CS_BLOB_PATH": "PublicTempStorage",
24+
"TMPMEDIA_DIR": "PrivateTempStorage",
25+
"PRINT_LAYOUT_METADATA_DIR": "LayoutMetadata",
26+
"StorageTimeZone": "1",
27+
"LOGIN_AS_USERID": "0",
28+
"LANGUAGE": "eng",
29+
"LANG_NAME": "English",
30+
"DECIMAL_POINT": ".",
31+
"DATE_FMT": "MDY",
32+
"CTOD_DATE_FMT": "L",
33+
"Culture": "en-US",
34+
"Theme": "Carmine",
35+
"UseNamedParameters": "1",
36+
"EnableIntegratedSecurity": "0",
37+
"MAX_CURSOR": "100",
38+
"STATIC_CONTENT": "",
39+
"GX_BUILD_NUMBER": "11103481",
40+
"CACHE_CONTENT_EXPIRATION": "36",
41+
"ENABLE_MANAGEMENT": "0",
42+
"COMPRESS_HTML": "1",
43+
"IE_COMPATIBILITY_VIEW": "EmulateIE7",
44+
"DocumentType": "HTML5",
45+
"EXPOSE_METADATA": "0",
46+
"SMART_CACHING": "0",
47+
"wcf:serviceHostingEnvironment:useClassicReadEntityBodyMode": "true",
48+
"HTTP_PROTOCOL": "Unsecure",
49+
"SAMESITE_COOKIE": "Lax",
50+
"CACHE_INVALIDATION_TOKEN": "20216211291931",
51+
"CORS_ALLOW_ORIGIN": "https://normal-website.com",
52+
"MY_CUSTOM_PTY": "DEFAULT_VALUE"
53+
},
54+
"languages": {
55+
"English": {
56+
"code": "eng",
57+
"culture": "en-US",
58+
"date_fmt": "MDY",
59+
"decimal_point": ".",
60+
"thousand_sep": ",",
61+
"time_fmt": "12"
62+
}
63+
}
64+
}

0 commit comments

Comments
 (0)