From d567b490908633162ec017d6cc3378fa03a477f7 Mon Sep 17 00:00:00 2001
From: Jesper Zedlitz <jesper.zedlitz@melund.landsh.de>
Date: Fri, 9 Apr 2021 11:34:17 +0200
Subject: [PATCH] =?UTF-8?q?Kopieren=20von=20Dateien=20w=C3=A4hrend=20des?=
 =?UTF-8?q?=20Harvest-Prozesses=20konfigurierbar?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 ckanext/odsh/logic/action.py | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/ckanext/odsh/logic/action.py b/ckanext/odsh/logic/action.py
index 0b4402db..a4cf48d8 100644
--- a/ckanext/odsh/logic/action.py
+++ b/ckanext/odsh/logic/action.py
@@ -5,6 +5,7 @@ import ckan.model as model
 import ckan.lib.dictization.model_dictize as model_dictize
 from ckan.lib.munge import munge_title_to_name
 import ckan.plugins.toolkit as toolkit
+from pylons import config
 from ckan.lib.search.common import make_connection, SearchError
 import pysolr
 import datetime
@@ -147,10 +148,14 @@ def autocomplete(context, data_dict):
 
 
 def odsh_resource_create(context, data_dict):
-    is_linked_resource = not isinstance(data_dict['upload'], cgi.FieldStorage)
-    if is_linked_resource:
-        _download_linked_resource_to_tmp(data_dict['url'])
-        _emulate_file_upload(data_dict)
+    copy_remote_resources = toolkit.asbool(
+        config.get('ckanext.odsh.copy_remote_resources', 'False')
+    )
+    if copy_remote_resources:
+      is_linked_resource = ( not 'upload' in data_dict ) or ( not isinstance(data_dict['upload'], cgi.FieldStorage))
+      if is_linked_resource:
+          _download_linked_resource_to_tmp(data_dict['url'])
+          _emulate_file_upload(data_dict)
     return resource_create(context, data_dict)
 
 TMP_FILE_PATH = '/tmp/temp_file_upload'
@@ -181,4 +186,4 @@ def _emulate_file_upload(data_dict):
     upload.headers['content-type'] = upload.type
     upload.name = 'upload'
     upload.filename = filename
-    data_dict['upload'] = upload
\ No newline at end of file
+    data_dict['upload'] = upload
-- 
GitLab