Skip to content

Conversation

@asiffermann
Copy link
Member

@asiffermann asiffermann commented Jan 6, 2017

Issues

Metadata handling

  • Azure: use Azure Blob Storage metadata and properties
  • FileSystem: use a IExtendedPropertiesProvider to get and save extended properties. A file system implementation to store JSON files next to the store folder has been created.

Breaking changes

  • No more automatic FetchProperties for the Azure Provider: it is now dependent of the withMetadata parameter
  • All the properties and metadata are now exposed on a IFileReference via a IFileProperties instance. For example, you should now access the Length like this: file.Properties.Length
  • There is no more AddMetadata method on IStore or on IFileReference. You should now modify metadata on the IFileProperties directly, and then call the method SavePropertiesAsync

@sandorfr
Copy link
Member

sandorfr commented Jan 8, 2017

I don't see mentioned IFileProperties changes. has it been pushed already?

@asiffermann
Copy link
Member Author

It's coming! I couldn't finish on friday as you came to disturb me! :p

var blockBlob = this.container.Value.GetBlockBlobReference(file.Path);
await blockBlob.UploadFromStreamAsync(data);
blockBlob.Properties.ContentType = contentType;
blockBlob.Properties.CacheControl = "max-age=300, must-revalidate";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe there is the chance to address #27 using freshly created FileProperties :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah! Saw that, I'm on it ;)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, the more I see this the more I think this is completely fucked up :D

blockBlob.Properties.CacheControl = "max-age=300, must-revalidate";
await blockBlob.SetPropertiesAsync();
return new Internal.AzureFileReference(blockBlob);
return new Internal.AzureFileReference(blockBlob, withMetadata: true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should make metadata loading optional here and add a withMetadata argument. Most save operation won't need them.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, it is not the loading that we specify here, but the fact that the properties and metadata are loaded :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are they?

Copy link
Member Author

@asiffermann asiffermann Jan 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the GetBlockBlobReference method initializes a reference with an empty dictionary for metadata, and the properties are set just the line before

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that since it's not a GetBlobReferenceFromServerAsync, it won't fetch pre-existing Metadata or Properties and one might end up overriding preexisting metadata.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you're right, didn't think of using this methods with existing Blobs...
There is already an issue in the current version with the properties being overwritten so.

Maybe we should check it the blob exists, and auto fetch properties in this case?

@asiffermann asiffermann added this to the 0.6.0 milestone Jan 9, 2017
@asiffermann
Copy link
Member Author

Ready to merge! I need your approbation @sandorfr and @arnaudauroux :)

{
var reference = InternalGetOrCreateAsync(file);
if (File.Exists(reference.FileSystemPath))
var data = File.ReadAllBytes(fileSystemPath);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should refrain from using ReadAllBytes kind of API in this library internals as they might be put the memory under high pressure. We should rely on a stream and a buffer using TransformBlock : https://msdn.microsoft.com/en-us/library/system.security.cryptography.hashalgorithm.transformblock(v=vs.110).aspx

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asiffermann this is not highest priority and might be tracked as an issue if you don't feel like addressing it now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better and simpler: md5.ComputeHash has an override that takes a Stream :)

Copy link
Member

@sandorfr sandorfr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job @galo

@asiffermann asiffermann merged commit 1b3e6b0 into develop Jan 10, 2017
@asiffermann asiffermann deleted the feature/enhanced-metadata branch January 10, 2017 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants