Skip to content

Commit a31fc24

Browse files
committed
Merge pull request #11 from tomfulton/fix/dict-exception
Fix exception updating CreatedDate when file exists
2 parents 42cd9e2 + f2a9cbb commit a31fc24

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/UmbracoFileSystemProviders.Azure/AzureFileSystem.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,14 @@ public void AddFile(string path, Stream stream, bool overrideIfExists)
216216
}
217217

218218
// Store the creation date in meta data.
219-
blockBlob.Metadata.Add("CreatedDate", created.ToString(CultureInfo.InvariantCulture));
219+
if (blockBlob.Metadata.ContainsKey("CreatedDate"))
220+
{
221+
blockBlob.Metadata["CreatedDate"] = created.ToString(CultureInfo.InvariantCulture);
222+
}
223+
else
224+
{
225+
blockBlob.Metadata.Add("CreatedDate", created.ToString(CultureInfo.InvariantCulture));
226+
}
220227
blockBlob.SetMetadata();
221228
}
222229
catch (Exception ex)

0 commit comments

Comments
 (0)