Get ful path from model on-the-fly to reduce memory consumsion

This commit is contained in:
rlv-dan 2020-04-28 19:12:04 +02:00
parent 688652a703
commit a622e419a1
2 changed files with 10 additions and 7 deletions

View File

@ -47,15 +47,18 @@ namespace Snap2HTML
this.Path = path; this.Path = path;
this.Properties = new Dictionary<string, string>(); this.Properties = new Dictionary<string, string>();
this.Files = new List<SnappedFile>(); this.Files = new List<SnappedFile>();
this.FullPath = ( this.Path + "\\" + this.Name ).Replace( "\\\\", "\\" );
} }
public string Name { get; set; } public string Name { get; set; }
public string Path { get; set; } public string Path { get; set; }
public string FullPath { get; set; }
public Dictionary<string, string> Properties { get; set; } public Dictionary<string, string> Properties { get; set; }
public List<SnappedFile> Files { get; set; } public List<SnappedFile> Files { get; set; }
public string GetFullPath()
{
return ( this.Path + "\\" + this.Name ).Replace( "\\\\", "\\" );
}
public string GetProp( string key ) public string GetProp( string key )
{ {
if( this.Properties.ContainsKey( key ) ) if( this.Properties.ContainsKey( key ) )

View File

@ -346,14 +346,14 @@ namespace Snap2HTML
var dirIndexes = new Dictionary<string, string>(); var dirIndexes = new Dictionary<string, string>();
for( var i = 0; i < content.Count; i++ ) for( var i = 0; i < content.Count; i++ )
{ {
dirIndexes.Add( content[i].FullPath, ( i + startIndex ).ToString() ); dirIndexes.Add( content[i].GetFullPath(), ( i + startIndex ).ToString() );
} }
// Build a lookup table with subfolder IDs for each folder // Build a lookup table with subfolder IDs for each folder
var subdirs = new Dictionary<string, List<string>>(); var subdirs = new Dictionary<string, List<string>>();
foreach( var dir in content ) foreach( var dir in content )
{ {
subdirs.Add( dir.FullPath, new List<string>() ); subdirs.Add( dir.GetFullPath(), new List<string>() );
} }
if( !subdirs.ContainsKey( content[0].Path ) && content[0].Name != "" ) if( !subdirs.ContainsKey( content[0].Path ) && content[0].Name != "" )
{ {
@ -365,7 +365,7 @@ namespace Snap2HTML
{ {
try try
{ {
subdirs[dir.Path].Add( dirIndexes[dir.FullPath] ); subdirs[dir.Path].Add( dirIndexes[dir.GetFullPath()] );
} }
catch( Exception ex ) catch( Exception ex )
{ {
@ -380,7 +380,7 @@ namespace Snap2HTML
{ {
result.Append( "D.p([" + lineBreakSymbol ); result.Append( "D.p([" + lineBreakSymbol );
var sDirWithForwardSlash = currentDir.FullPath.Replace( @"\", "/" ); var sDirWithForwardSlash = currentDir.GetFullPath().Replace( @"\", "/" );
result.Append( "\"" ).Append( Utils.MakeCleanJsString( sDirWithForwardSlash ) ).Append( "*" ).Append( "0" ).Append( "*" ).Append( currentDir.GetProp( "Modified" ) ).Append( "\"," + lineBreakSymbol ); result.Append( "\"" ).Append( Utils.MakeCleanJsString( sDirWithForwardSlash ) ).Append( "*" ).Append( "0" ).Append( "*" ).Append( currentDir.GetProp( "Modified" ) ).Append( "\"," + lineBreakSymbol );
long dirSize = 0; long dirSize = 0;
@ -395,7 +395,7 @@ namespace Snap2HTML
result.Append( "" ).Append( dirSize ).Append( "," + lineBreakSymbol ); result.Append( "" ).Append( dirSize ).Append( "," + lineBreakSymbol );
// Add reference to subdirs // Add reference to subdirs
result.Append( "\"" ).Append( String.Join( "*", subdirs[currentDir.FullPath].ToArray() ) ).Append( "\"" + lineBreakSymbol ); // subdirs result.Append( "\"" ).Append( String.Join( "*", subdirs[currentDir.GetFullPath()].ToArray() ) ).Append( "\"" + lineBreakSymbol ); // subdirs
// Finalize // Finalize
result.Append( "])" ); result.Append( "])" );