private void UpdateMetadata(PostedDataDto postedData, Action <MetadataContext> updateMethod) { using (var inputStream = fileService.GetFileStream(postedData.guid, false)) using (MetadataContext context = new MetadataContext(inputStream, postedData.password)) { updateMethod(context); context.Save(); } }
public void CleanMetadata(PostedDataDto postedData) { string filePath = metadataConfiguration.GetAbsolutePath(postedData.guid); var tempFilePath = GetTempPath(filePath); using (MetadataContext context = new MetadataContext(filePath, postedData.password)) { context.Sanitize(); context.Save(tempFilePath); } DirectoryUtils.MoveFile(tempFilePath, filePath); }
public void RemoveProperties(PostedDataDto postedData) { string filePath = metadataConfiguration.GetAbsolutePath(postedData.guid); var tempFilePath = GetTempPath(filePath); using (MetadataContext context = new MetadataContext(filePath, postedData.password)) { foreach (var packageInfo in postedData.packages) { context.RemoveProperties(packageInfo.id, packageInfo.properties.Select(p => p.name)); } context.Save(tempFilePath); } DirectoryUtils.MoveFile(tempFilePath, filePath); }