Prevent acquisition of content streams for remote only data

This commit is contained in:
John Lewin 2017-09-28 17:36:42 -07:00
parent b6a2654899
commit 040d3dc934
6 changed files with 11 additions and 6 deletions

View file

@ -126,8 +126,9 @@ namespace MatterHackers.MatterControl
{
IObject3D object3D = null;
var contentModel = item as ILibraryContentStream;
if (contentModel != null
if (item is ILibraryContentStream contentModel
// Only load the stream if it's available - prevents download of internet content simply for thumbnails
&& contentModel.LocalContentExists
&& contentModel.FileSize < MaxFileSizeForTracing)
{
// TODO: Wire up limits for thumbnail generation. If content is too big, return null allowing the thumbnail to fall back to content default

View file

@ -58,6 +58,8 @@ namespace MatterHackers.MatterControl.Library
string ContentType { get; }
string FileName { get; }
string AssetPath { get; }
bool LocalContentExists { get; }
Task<StreamAndLength> GetContentStream(Action<double, string> progress);
}
}

View file

@ -43,7 +43,8 @@ namespace MatterHackers.MatterControl.Library
public string ThumbnailKey { get; set; } = "";
public virtual bool IsProtected => false;
public virtual bool IsVisible => true;
public virtual bool LocalContentExists => true;
public FileSystemItem(string path)
{
this.Path = path;

View file

@ -79,7 +79,7 @@ namespace MatterHackers.MatterControl.Library
return new FileSystemFileItem(AggContext.StaticData.MapPath(s));
}).ToList<ILibraryItem>();
UiThread.RunOnIdle(this.OnReloaded);
UiThread.RunOnIdle(this.OnReloaded);
});
}

View file

@ -63,6 +63,8 @@ namespace MatterHackers.MatterControl.Library
public bool IsVisible => true;
public bool LocalContentExists => true;
public Task<StreamAndLength> GetContentStream(Action<double, string> reportProgress)
{
throw new NotImplementedException();

View file

@ -117,8 +117,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
{
// Ask content provider - allows type specific thumbnail creation
var contentProvider = ApplicationController.Instance.Library.GetContentProvider(itemModel);
if (contentProvider != null
&& contentProvider is MeshContentProvider)
if (contentProvider is MeshContentProvider)
{
// Before we have a thumbnail set to the content specific thumbnail
thumbnail = contentProvider.DefaultImage;