From 68dff595cf61fe788bfccc7b9f85884baf332d1c Mon Sep 17 00:00:00 2001
From: Daniel Neuwirth <daniel.neuwirth@dataport.de>
Date: Tue, 29 Oct 2019 08:28:20 +0000
Subject: [PATCH] Hash algoirthm for rdf

---
 ckanext/odsh/tools.py | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/ckanext/odsh/tools.py b/ckanext/odsh/tools.py
index ca7d69a7..22b999b3 100644
--- a/ckanext/odsh/tools.py
+++ b/ckanext/odsh/tools.py
@@ -9,9 +9,10 @@ def save_hash_into_resource(context, resource):
         with open(path, 'rb') as file:
             hash = calculate_hash(file)
             package = update_last_resource_if_value_empty(context, resource, 'hash', hash)
+            resources = package.get('resources')
+            last_resource = resources.pop()    
+            if last_resource.get(hash) and not last_resource.get('hash_algorithm'): 
+                last_resource.update({'hash_algorithm': 'http://dcat-ap.de/def/hashAlgorithms/md/5'})
+                resources.append(last_resource)
+                package.update({'resources':resources})
         toolkit.get_action('package_update')(context, package)
-
-    
-
-
-
-- 
GitLab