Skip to content

Commit f2a9cbb

Browse files
committed
Fix exception updating CreatedDate when file exists
1 parent 15fbd45 commit f2a9cbb

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)