Skip to content

Commit

Permalink
release 3.8.1 dont clean empty dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
pofider committed Oct 5, 2022
1 parent f3351a3 commit 2aaf2c5
Show file tree
Hide file tree
Showing 12 changed files with 110 additions and 31 deletions.
27 changes: 24 additions & 3 deletions jsreport.Local.Test/LocalWebServerReportingTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ public class LocalWebServerReportingTest

[SetUp]
public async Task SetUp()
{
_rs = new LocalReporting().UseBinary(JsReportBinary.GetBinary()).AsWebServer().Create();
{
Console.WriteLine(Path.Combine(Directory.GetCurrentDirectory(), "jsreportCopyAlways"));
_rs = new LocalReporting()
.UseBinary(JsReportBinary.GetBinary())
.RunInDirectory(Path.Combine(Directory.GetCurrentDirectory(), "jsreportCopyAlways"))
.Configure((cfg) => cfg.FileSystemStore())
.AsWebServer()
.Create();
await _rs.StartAsync();
}

Expand All @@ -45,7 +51,22 @@ public async Task TestWebServerRender()

new StreamReader(result.Content).ReadToEnd().ShouldBe("Hello world");
}
}


[Test]
public async Task TestWebServerRenderWithName()
{
var result = await _rs.RenderAsync(new RenderRequest()
{
Template = new Template()
{
Name = "test"
}
});

result.Meta.ContentType.ShouldBe("application/pdf");
}
}

[TestFixture]
[SingleThreaded]
Expand Down
6 changes: 6 additions & 0 deletions jsreport.Local.Test/jsreport.Local.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
<Folder Include="jsreportTest\" />
</ItemGroup>

<ItemGroup>
<None Include="jsreportCopyAlways\**\*.*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<Choose>
<When Condition=" '$(SolutionName)' == 'jsreport.development' ">
<ItemGroup>
Expand Down
12 changes: 12 additions & 0 deletions jsreport.Local.Test/jsreportCopyAlways/data/folderA/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "folderA",
"creationDate": {
"$$date": 1664971693720
},
"modificationDate": {
"$$date": 1664971693720
},
"shortid": "yCM89eL",
"_id": "Lh1SpWIqGOIyYWLJ",
"$entitySet": "folders"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "folderB",
"creationDate": {
"$$date": 1664971703590
},
"modificationDate": {
"$$date": 1664971703590
},
"shortid": "chIlz9Q",
"_id": "GmOotpwU9nkZVU1K",
"$entitySet": "folders"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "test",
"engine": "handlebars",
"recipe": "chrome-pdf",
"shortid": "jBZAn34xh",
"chrome": {
"printBackground": true
},
"creationDate": {
"$$date": 1664971709664
},
"modificationDate": {
"$$date": 1664971709664
},
"_id": "1DMiDBYkCkdGq7mR",
"$entitySet": "templates"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello
21 changes: 21 additions & 0 deletions jsreport.Local.Test/jsreportCopyAlways/data/fs.journal
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

{"operation":"remove","timestamp":{"$$date":1664971690307},"version":26,"doc":{"_id":"ISMeECK0zemkHPir","$entitySet":"templates"}}
{"operation":"remove","timestamp":{"$$date":1664971690350},"version":27,"doc":{"_id":"1LXyFauSeTBKO18F","$entitySet":"data"}}
{"operation":"remove","timestamp":{"$$date":1664971690360},"version":28,"doc":{"_id":"CoJiO5LgfYtwQaYJ","$entitySet":"assets"}}
{"operation":"remove","timestamp":{"$$date":1664971690368},"version":29,"doc":{"_id":"tsEfH0nOyW8i4Gjt","$entitySet":"assets"}}
{"operation":"remove","timestamp":{"$$date":1664971690376},"version":30,"doc":{"_id":"rAjHSsr8TC3ocOOB","$entitySet":"folders"}}
{"operation":"remove","timestamp":{"$$date":1664971690388},"version":31,"doc":{"_id":"lTWQJLpenvQMaamf","$entitySet":"templates"}}
{"operation":"remove","timestamp":{"$$date":1664971690399},"version":32,"doc":{"_id":"dpaebImjjaoprpjp","$entitySet":"templates"}}
{"operation":"remove","timestamp":{"$$date":1664971690406},"version":33,"doc":{"_id":"qOL8ZPvDuIhB0LG1","$entitySet":"assets"}}
{"operation":"remove","timestamp":{"$$date":1664971690413},"version":34,"doc":{"_id":"AjT297OX9EImZIS5","$entitySet":"scripts"}}
{"operation":"remove","timestamp":{"$$date":1664971690418},"version":35,"doc":{"_id":"lHuYUSbnCqooI21X","$entitySet":"folders"}}
{"operation":"remove","timestamp":{"$$date":1664971690425},"version":36,"doc":{"_id":"n4KLqe1DMZUgPuSs","$entitySet":"templates"}}
{"operation":"remove","timestamp":{"$$date":1664971690434},"version":37,"doc":{"_id":"2m9kHaurFaZcuEi5","$entitySet":"data"}}
{"operation":"remove","timestamp":{"$$date":1664971690443},"version":38,"doc":{"_id":"ytYEs2z5HE6FQkNI","$entitySet":"assets"}}
{"operation":"remove","timestamp":{"$$date":1664971690451},"version":39,"doc":{"_id":"XlszevBtFwPPMtaD","$entitySet":"folders"}}
{"operation":"remove","timestamp":{"$$date":1664971690459},"version":40,"doc":{"_id":"HKEr1WkiraBa5IQ2","$entitySet":"assets"}}
{"operation":"remove","timestamp":{"$$date":1664971690470},"version":41,"doc":{"_id":"Lb87mcnQD6HXGknU","$entitySet":"folders"}}
{"operation":"remove","timestamp":{"$$date":1664971690478},"version":42,"doc":{"_id":"3FHHzvw9ouZzSdF1","$entitySet":"folders"}}
{"operation":"insert","timestamp":{"$$date":1664971693727},"version":43,"doc":{"folder":null,"name":"folderA","creationDate":{"$$date":1664971693720},"modificationDate":{"$$date":1664971693720},"shortid":"yCM89eL","_id":"Lh1SpWIqGOIyYWLJ","$entitySet":"folders","$$etag":1664971693727}}
{"operation":"insert","timestamp":{"$$date":1664971703597},"version":44,"doc":{"folder":{"shortid":"yCM89eL"},"name":"folderB","creationDate":{"$$date":1664971703590},"modificationDate":{"$$date":1664971703590},"shortid":"chIlz9Q","_id":"GmOotpwU9nkZVU1K","$entitySet":"folders","$$etag":1664971703597}}
{"operation":"insert","timestamp":{"$$date":1664971709701},"version":45,"doc":{"folder":{"shortid":"chIlz9Q"},"name":"test","engine":"handlebars","recipe":"chrome-pdf","shortid":"jBZAn34xh","chrome":{"printBackground":true},"content":"hello","creationDate":{"$$date":1664971709664},"modificationDate":{"$$date":1664971709664},"_id":"1DMiDBYkCkdGq7mR","$entitySet":"templates","$$etag":1664971709700}}
1 change: 1 addition & 0 deletions jsreport.Local.Test/jsreportCopyAlways/data/fs.version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
45
5 changes: 5 additions & 0 deletions jsreport.Local.Test/jsreportCopyAlways/data/settings
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{"key":"core-migrated-xlsxTemplates","value":"true","creationDate":{"$$date":1664968353919},"modificationDate":{"$$date":1664968353919},"shortid":"C6r-Tzl","_id":"79eW6OO49OXs3OIf","$entitySet":"settings"}
{"key":"core-migrated-resources","value":"true","creationDate":{"$$date":1664968353971},"modificationDate":{"$$date":1664968353971},"shortid":"0j-iX5v","_id":"7WX0k77q8OCf9Zcf","$entitySet":"settings"}
{"key":"core-migrated-versionControl-props","value":"true","creationDate":{"$$date":1664968354551},"modificationDate":{"$$date":1664968354551},"shortid":"-EMAcWM","_id":"5q4f82hn4YPiWQXr","$entitySet":"settings"}
{"key":"chrome-network-idle-migrated","value":"true","creationDate":{"$$date":1664968354567},"modificationDate":{"$$date":1664968354567},"shortid":"qKum6Vg","_id":"RRsT43nHUQZbItPd","$entitySet":"settings"}
{"key":"sample-created","value":"true","creationDate":{"$$date":1664968354585},"modificationDate":{"$$date":1664968354585},"shortid":"ESmcNAt","_id":"MCS0N9jozTtTl68G","$entitySet":"settings"}
6 changes: 6 additions & 0 deletions jsreport.Local.Test/jsreportTest/data/templates/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"_id": "uF8glLrREmplHQ2H",
"shortid": "qZ0qh8",
"$entitySet": "folders",
"name": "templates"
}
27 changes: 2 additions & 25 deletions jsreport.Local/Internal/BinaryProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ internal async Task EnsureInitialized()
if (_initialized)
{
return;
}

CleanEmptyDataFolders();
}

var jsreportBinaryDirectory = Path.Combine(Configuration.TempDirectory, "dotnet", "binary-" + _binary.UniqueId);
Directory.CreateDirectory(jsreportBinaryDirectory);
Expand Down Expand Up @@ -202,28 +200,7 @@ private static byte[] ReadFully(Stream input)
input.CopyTo(ms);
return ms.ToArray();
}
}

// visual studio always keeps some empty folders after build even the whole jsreport is set to Copy Always
// we need to delete these old empty folders to avoid nedb failures on start
private void CleanEmptyDataFolders()
{
var data = Path.Combine(_workingPath, "data");

if (!Directory.Exists(data))
{
return;
}

Directory.GetDirectories(data).ToList().ForEach(d => Directory.GetDirectories(d).ToList().ForEach(nd =>
{
// nd is entity folder like Template1
if (!Directory.EnumerateFiles(nd).Any())
{
Directory.Delete(nd);
}
}));
}
}

private string Shortid()
{
Expand Down
6 changes: 3 additions & 3 deletions jsreport.Local/jsreport.Local.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageReleaseNotes>Release notes are at https://github.com/jsreport/jsreport-dotnet-local/releases</PackageReleaseNotes>
<Version>3.8.0</Version>
<Version>3.8.1</Version>
<Authors>Jan Blaha</Authors>
<Company>jsreport</Company>
<Product>jsreport</Product>
Expand All @@ -15,8 +15,8 @@
<RepositoryUrl>https://github.com/jsreport/jsreport-dotnet</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>jsreport;report;pdf;excel</PackageTags>
<AssemblyVersion>3.8.0.0</AssemblyVersion>
<FileVersion>3.8.0.0</FileVersion>
<AssemblyVersion>3.8.1.0</AssemblyVersion>
<FileVersion>3.8.1.0</FileVersion>
<Description>pdf or excel reports rendering through local jsreport binary</Description>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageIcon>icon.png</PackageIcon>
Expand Down

0 comments on commit 2aaf2c5

Please sign in to comment.