-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP - Initial help/work to get this working for V8.0.0 #135
WIP - Initial help/work to get this working for V8.0.0 #135
Conversation
… order to update references in projects
@warrenbuckley great stuff! I was discussing with @zpqrtbnk a week before the holidays about what changes would be needed to port this over. If there's anything I can do to support/test please let me know! |
Do final fixes to get this to compile - still need to implement couple of things
@Jeavon it will probably be test/tidy up my initial work - it currently compiles but I need to head off for today. |
…so updating tests to reflect this. Note: slight concern about non media usages of this provider such as UmbracoForms
Seems like we are close @Jeavon and I can add my first set of notes to my working document for common package upgrade notes for developers. |
Think the ZIP package won't work for now as think we (HQ) have not done much work with packages in V8 Core as of yet nor know whats planned for it. |
Man that |
@JimBobSquarePants feel free after I submit this to use the DI Container instead - but for quickness & to help easily port stuff then But please lets not get into a DI debate etc here. I just wanted to help port this over as quickly as possible so that it will continue to work on V8 when it gets released. |
Seems perfectly valid to return a not implemented for the new AddFile method - due to the bool CanAddPhysical is false/not implemeted as well
I'm not sure if @zpqrtbnk got around to filesystems yet, but it's hopefully being tweaked more. I'm making a note to revisit this. In the mean time, |
I am not sure - will ask @zpqrtbnk when I am back at work officially on Monday to see if there is more tweaks to be done to Like I said for now I will use The only thing that is problematic is the ZIP based package & the post configuration view |
<package id="Microsoft.AspNet.WebApi.Core" version="4.0.30506.0" targetFramework="net45" /> | ||
<package id="Microsoft.AspNet.WebApi.WebHost" version="4.0.30506.0" targetFramework="net45" /> | ||
<package id="Microsoft.AspNet.WebPages" version="2.0.20710.0" targetFramework="net45" /> | ||
<package id="LightInject" version="5.1.2" targetFramework="net472" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these explicitly required? I'm seeing a lot of references here that I would expect to be implicit.
<package id="Microsoft.AspNet.WebApi.WebHost" version="4.0.30506.0" targetFramework="net45" /> | ||
<package id="Microsoft.AspNet.WebPages" version="2.0.20710.0" targetFramework="net45" /> | ||
<package id="LightInject" version="5.1.2" targetFramework="net472" /> | ||
<package id="LightInject.Annotation" version="1.1.0" targetFramework="net472" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above. Lot's of new explicit references.
|
||
if (blockBlob != null) | ||
{ | ||
return blockBlob.Properties.Length; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Properties
can be null can it not?
I do wonder whether this should be an independant package for V8? If I were redesigning the
|
What?? I don't understand why there should be any additional complexity at all. It all smells of some unfortunate architectural decisions in Umbraco. There's no way I want to suddenly maintain multiple projects. V8 was supposed to make things simpler!! Here's how it should work:
Our package should implement |
@@ -68,7 +69,7 @@ public override Stream Open() | |||
// Add Accept-Ranges header to fix videos not playing on Safari | |||
HttpContext.Current.Response.AppendHeader("Accept-Ranges", "bytes"); | |||
|
|||
IFileSystem azureBlobFileSystem = FileSystemProviderManager.Current.GetUnderlyingFileSystemProvider("media"); | |||
IFileSystem azureBlobFileSystem = Current.MediaFileSystem.Unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks absolutely mental to me. Unwrap()
? The IFileSystem
should be injectable.
@JimBobSquarePants This is an area which we've tried to simplify, but not sure we're there yet. It goes like this. All this package should provide is, indeed, an Now, how do we know which In v7 this is done in a config file, with a fair amount of pseudo DI. To clean things up, we've moved to configuration by code. Also, there are many different The only other proper way I see... thinking of it... is to create an interface Do you see the problem? Am I confused by too much thinking, and do you see a much simpler solution? |
I don't think I ever understood why "we don't want named services"? |
@lars-erik how do you indicate you want to inject the |
@zpqrtbnk With the current implementation, the only way without more component metadata is to say so in a factory method. IE. |
Discussion had off-site. I'll research naming with MS.DI while @zpqrtbnk will make it work with IRegister/IFactory/LI for now. |
@zpqrtbnk I get why you don't want to do it via named services since that would require an explicit implementation. There's a couple of ways that you could do this. Here's an example one way using factories with keys. That's OK but I think we can maybe do better. First define your types and interfaces // Used to identify where the filesystem should be used.
public enum FileSystemScope
{
Media,
Templates,
StyleSheets,
// You can keep extending this ad infinitum.
} IFileSystem
{
FileSystemScope Scope { get; }
} // By scoping this file system to a particular domain we can use different containers
// for different domains if need be.
// Any underlying CRUD code would be simple enough and could be shared across
// the implementations.
public class AzureMediaFileSystem : IFileSystem
{
public FileSystemScope Scope { get; } = FileSystemScope.Media;
} Then your consuming class... // MediaFileSystem is a bad name btw. It's mixing the caller and callee names which is confusing.
public class MediaManager : IMediaManager
{
private readonly IFileSystem fielsystem;
public MediaManager(IEnumerable<FileSystem> filesystems)
{
// You could register some sort of factory that does this lookup for you if you liked
// and pass that through the constructor instead.
this.filesystem = filesystems.First(x => x.Scope == FileSystemScope.Media);
}
} Registration in Jamestopia would be performed by the availability of a method as follows. // IUmbracoBuilder is an extensible interface + implementation that you can pass to your startup.
public static IUmbracoBuilder ReplaceMediaFileSystem<TFileSystem, TFileSystem2>(this IUmbracoBuilder builder)
where TFileSystem : class, IFileSystem
where TFileSystem2 : class, IFileSystem
{
// I dunno if it's possible to ensure at compile time whether it's the IFileSystem is using the
// correct FileSystemScope but you'd soon get a warning anyway.
// Services is IServiceCollection
builder.Services.Remove(ServiceDescriptor.Singleton<IFileSystem, TFileSystem>());
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<IFileSystem, TFileSystem2>());
return builder;
} It's a pretty simple approach really that you can build easily enough since you know the areas of scope. The same principle could be applied to other areas of the codebase I'm sure also. |
You guys are heroes ❤️ let me know if you need help testing or whatever. |
Any updates on this @zpqrtbnk @lars-erik or @JimBobSquarePants ?! Can I carry working on this or you still discussing some changes for V8 core related to this?! |
@warrenbuckley Things are happening. See #v8-di on community slack. |
Will go & have a nose and catch-up what’s been going on |
…aller project will need reworking anyway
OK after the recent V8 core FileSystem changes that @lars-erik & @JimBobSquarePants have been in discussion with @zpqrtbnk that has been merged into the V8 core. umbraco/Umbraco-CMS#4028 I have updated this PR again to make it work, currently it works with AppSetting keys. |
src/UmbracoFileSystemProviders.Azure/AzureFileSystemComponent.cs
Outdated
Show resolved
Hide resolved
@lars-erik I have done the change you suggested & this currently all works. However it feels I am getting deeper and deeper into the existing codebase, so I would love it if one of the three of you who are collaborators on this project, are able to do any further refactoring or changes that you would like to see, direct on this PR please. Cheers, |
Tbh mate I'd like to refactor the entire library from scratch no that we will have proper DI to utilize. If it's working now I'm happy to merge current progress in.
Totally forgot I could change the base! |
@warrenbuckley While I have your attention I do have some further questions regarding We currently have to use a virtual path provider in order to serve relative files. It's really shitty for us to have to do so because it shouldn't be a concern of ours - We should just return the values, Umbraco should serve them. Does Umbraco still save the paths in the DB? if so, can it not? Relative files should simply be the way it works. I want to delete our VPP. Have any updates been made to ensure that the correct response headers are served? We currently have to do a hack, again in the virtual path provider, adding headers like |
/// <summary> | ||
/// The maximum number of days to cache blob items for in the browser | ||
/// </summary> | ||
public string MaxDays { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is because the Pseudo-DI that V7 uses when parsing the configuration originally passes the parameters as strings. Change them to the real deal anytime.
@JimBobSquarePants to answer your couple of questions I don't have any definitive answers for you now. As far as I know, this will have to stay the same for now, How shall we move this forward, are you happy to merge it in and then build/work upon the initial changes I have done so you can refactor & tweak as you please. |
@warrenbuckley Yeah, now I've changed the target we can merge this as. Thanks for making a start! 👍 |
65448c6
into
umbraco-community:develop-umbraco-version-8
Hiya @Jeavon @JimBobSquarePants @lars-erik
This is a WIP PR where I will try & find some time in the evening's or during lunchtime hacks, to get this package re-targeted for V8.0.0
Will post updates/notes as I go along...