Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package orthanc for openSUSE:Factory checked 
in at 2021-07-23 23:41:16
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/orthanc (Old)
 and      /work/SRC/openSUSE:Factory/.orthanc.new.1899 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "orthanc"

Fri Jul 23 23:41:16 2021 rev:17 rq:907938 version:1.9.6

Changes:
--------
--- /work/SRC/openSUSE:Factory/orthanc/orthanc.changes  2021-07-20 
15:39:50.329512592 +0200
+++ /work/SRC/openSUSE:Factory/.orthanc.new.1899/orthanc.changes        
2021-07-23 23:41:37.917799124 +0200
@@ -1,0 +2,8 @@
+Thu Jul 22 13:34:16 UTC 2021 - Axel Braun <axel.br...@gmx.de>
+
+- version 1.9.6 
+* In lookup and query/retrieve, possibility to provide a specific study date
+* Clicking on "Send to remote modality" displays the job information to 
monitor progress
+* Fix orphaned attachments if bad revision number is provided
+
+-------------------------------------------------------------------

Old:
----
  Orthanc-1.9.5.tar.gz

New:
----
  Orthanc-1.9.6.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ orthanc.spec ++++++
--- /var/tmp/diff_new_pack.QTEefS/_old  2021-07-23 23:41:38.505798372 +0200
+++ /var/tmp/diff_new_pack.QTEefS/_new  2021-07-23 23:41:38.509798367 +0200
@@ -18,7 +18,7 @@
 
 
 Name:           orthanc
-Version:        1.9.5
+Version:        1.9.6
 Release:        0
 Summary:        RESTful DICOM server for healthcare and medical research
 License:        GPL-3.0-or-later

++++++ Orthanc-1.9.5.tar.gz -> Orthanc-1.9.6.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Orthanc-1.9.5/.hg_archival.txt 
new/Orthanc-1.9.6/.hg_archival.txt
--- old/Orthanc-1.9.5/.hg_archival.txt  2021-07-08 09:44:49.000000000 +0200
+++ new/Orthanc-1.9.6/.hg_archival.txt  2021-07-21 10:26:20.000000000 +0200
@@ -1,6 +1,6 @@
 repo: 3959d33612ccaadc0d4d707227fbed09ac35e5fe
-node: c26a87e0fed76dba1882e9310fad333b4c185fb0
-branch: Orthanc-1.9.5
+node: b1319a5304fb494e567e32dc53aa11a6978eb554
+branch: Orthanc-1.9.6
 latesttag: toa2020012703
-latesttagdistance: 917
-changessincelatesttag: 1081
+latesttagdistance: 928
+changessincelatesttag: 1093
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Orthanc-1.9.5/NEWS new/Orthanc-1.9.6/NEWS
--- old/Orthanc-1.9.5/NEWS      2021-07-08 09:44:49.000000000 +0200
+++ new/Orthanc-1.9.6/NEWS      2021-07-21 10:26:20.000000000 +0200
@@ -2,6 +2,21 @@
 ===============================
 
 
+Version 1.9.6 (2021-07-21)
+==========================
+
+Orthanc Explorer
+----------------
+
+* In lookup and query/retrieve, possibility to provide a specific study date
+* Clicking on "Send to remote modality" displays the job information to 
monitor progress
+
+Maintenance
+-----------
+
+* Fix orphaned attachments if bad revision number is provided
+
+
 Version 1.9.5 (2021-07-08)
 ==========================
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/Orthanc-1.9.5/OrthancFramework/Resources/CMake/DownloadOrthancFramework.cmake
 
new/Orthanc-1.9.6/OrthancFramework/Resources/CMake/DownloadOrthancFramework.cmake
--- 
old/Orthanc-1.9.5/OrthancFramework/Resources/CMake/DownloadOrthancFramework.cmake
   2021-07-08 09:44:49.000000000 +0200
+++ 
new/Orthanc-1.9.6/OrthancFramework/Resources/CMake/DownloadOrthancFramework.cmake
   2021-07-21 10:26:20.000000000 +0200
@@ -132,6 +132,8 @@
         set(ORTHANC_FRAMEWORK_MD5 "9b86e6f00e03278293cd15643cc0233f")
       elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.9.4")
         set(ORTHANC_FRAMEWORK_MD5 "6d5ca4a73ac7d42445041ca79de1624d")
+      elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.9.5")
+        set(ORTHANC_FRAMEWORK_MD5 "10fc64de1254a095e5d3ed3931f0cfbb")
 
       # Below this point are development snapshots that were used to
       # release some plugin, before an official release of the Orthanc
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/Orthanc-1.9.5/OrthancFramework/Resources/CMake/OrthancFrameworkParameters.cmake
 
new/Orthanc-1.9.6/OrthancFramework/Resources/CMake/OrthancFrameworkParameters.cmake
--- 
old/Orthanc-1.9.5/OrthancFramework/Resources/CMake/OrthancFrameworkParameters.cmake
 2021-07-08 09:44:49.000000000 +0200
+++ 
new/Orthanc-1.9.6/OrthancFramework/Resources/CMake/OrthancFrameworkParameters.cmake
 2021-07-21 10:26:20.000000000 +0200
@@ -23,7 +23,7 @@
 #####################################################################
 
 # Version of the build, should always be "mainline" except in release branches
-set(ORTHANC_VERSION "1.9.5")
+set(ORTHANC_VERSION "1.9.6")
 
 # Version of the database schema. History:
 #   * Orthanc 0.1.0 -> Orthanc 0.3.0 = no versioning
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/Orthanc-1.9.5/OrthancFramework/Sources/Compression/ZipReader.cpp 
new/Orthanc-1.9.6/OrthancFramework/Sources/Compression/ZipReader.cpp
--- old/Orthanc-1.9.5/OrthancFramework/Sources/Compression/ZipReader.cpp        
2021-07-08 09:44:49.000000000 +0200
+++ new/Orthanc-1.9.6/OrthancFramework/Sources/Compression/ZipReader.cpp        
2021-07-21 10:26:20.000000000 +0200
@@ -38,7 +38,7 @@
 
 /**
  * I have not been able to correctly define "ssize_t" on all versions
- * of Visual Studio. As a consequence, I prefered to switch "ssize_t"
+ * of Visual Studio. As a consequence, I preferred to switch "ssize_t"
  * to "SSIZE_T", that is properly defined on both MSVC 2008 and 2015.
  * I define the macro "SSIZE_T" as an alias to "ssize_t" on
  * POSIX-compliant platforms that wouldn't have "SSIZE_T" defined.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/Orthanc-1.9.5/OrthancFramework/Sources/Compression/ZipWriter.cpp 
new/Orthanc-1.9.6/OrthancFramework/Sources/Compression/ZipWriter.cpp
--- old/Orthanc-1.9.5/OrthancFramework/Sources/Compression/ZipWriter.cpp        
2021-07-08 09:44:49.000000000 +0200
+++ new/Orthanc-1.9.6/OrthancFramework/Sources/Compression/ZipWriter.cpp        
2021-07-21 10:26:20.000000000 +0200
@@ -452,7 +452,7 @@
     }
     catch (OrthancException& e)  // Don't throw exceptions in destructors
     {
-      LOG(ERROR) << "Catched exception in destructor: " << e.What();
+      LOG(ERROR) << "Caught exception in destructor: " << e.What();
     }
   }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/Orthanc-1.9.5/OrthancServer/OrthancExplorer/explorer.html 
new/Orthanc-1.9.6/OrthancServer/OrthancExplorer/explorer.html
--- old/Orthanc-1.9.5/OrthancServer/OrthancExplorer/explorer.html       
2021-07-08 09:44:49.000000000 +0200
+++ new/Orthanc-1.9.6/OrthancServer/OrthancExplorer/explorer.html       
2021-07-21 10:26:20.000000000 +0200
@@ -87,6 +87,11 @@
           </select>
         </div>
 
+        <div data-role="fieldcontain">
+          <label for="lookup-study-date-specific"></label>
+          <input type="date" name="lookup-study-date-specific" 
id="lookup-study-date-specific" />
+        </div>
+
         <fieldset class="ui-grid-b">
           <div class="ui-block-a">
             <a href="#find-patients" data-role="button" data-theme="b" 
data-direction="reverse">All patients</a>
@@ -494,7 +499,7 @@
 
         <div data-role="fieldcontain">
           <label for="qr-value">Value for this field:</label>
-          <input type="text" name="qr-value" id="qr-value" value="*" />
+          <input type="text" name="qr-value" id="qr-value" value="" />
         </div>
 
         <div data-role="fieldcontain">
@@ -503,6 +508,11 @@
           </select>
         </div>
 
+        <div data-role="fieldcontain">
+          <label for="qr-date-specific"></label>
+          <input type="date" name="qr-date-specific" id="qr-date-specific" />
+        </div>
+
         <div data-role="fieldcontain" id="qr-modalities">
           <div data-role="fieldcontain">
             <fieldset data-role="controlgroup" data-type="horizontal">
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/Orthanc-1.9.5/OrthancServer/OrthancExplorer/explorer.js 
new/Orthanc-1.9.6/OrthancServer/OrthancExplorer/explorer.js
--- old/Orthanc-1.9.5/OrthancServer/OrthancExplorer/explorer.js 2021-07-08 
09:44:49.000000000 +0200
+++ new/Orthanc-1.9.6/OrthancServer/OrthancExplorer/explorer.js 2021-07-21 
10:26:20.000000000 +0200
@@ -506,23 +506,39 @@
   target.append($('<option>').attr('value', GenerateDicomDate(-31) + 
'-').text('Last 31 days'));
   target.append($('<option>').attr('value', GenerateDicomDate(-31 * 3) + 
'-').text('Last 3 months'));
   target.append($('<option>').attr('value', GenerateDicomDate(-365) + 
'-').text('Last year'));
+  target.append($('<option>').attr('value', 'specific').text('Specific date'));
   target.selectmenu('refresh');
 
   $('#lookup-result').hide();
+  $('#lookup-study-date-specific').hide();
+});
+
+
+$('#lookup-study-date').live('change', function() {
+  if ($(this).val() == 'specific') {
+    $('#lookup-study-date-specific').show();
+  } else {
+    $('#lookup-study-date-specific').hide();
+  }
 });
 
 
 $('#lookup-submit').live('click', function() {
-  var lookup;
+  var lookup, studyDate;
 
   $('#lookup-result').hide();
 
+  studyDate = $('#lookup-study-date').val();
+  if (studyDate == 'specific') {
+    studyDate = IsoToDicomDate($('#lookup-study-date-specific').val());
+  }
+  
   lookup = {
     'Level' : 'Study',
     'Expand' : true,
     'Limit' : LIMIT_RESOURCES + 1,
     'Query' : {
-      'StudyDate' : $('#lookup-study-date').val()
+      'StudyDate' : studyDate
     },
     'Full' : true
   };
@@ -541,6 +557,9 @@
       else if (input.id == 'lookup-study-description') {
         lookup['Query']['StudyDescription'] = input.value;
       }
+      else if (input.id == 'lookup-study-date-specific') {
+        // Ignore
+      }
       else {
         console.error('Unknown lookup field: ' + input.id);
       }
@@ -1260,19 +1279,23 @@
     }
 
     if (url != '') {
+      /**
+       * In Orthanc <= 1.9.5, synchronous job was used, which caused a
+       * non-intuitive behavior because of AJAX timeouts on large
+       * studies. We now use an asynchronous call.
+       * https://groups.google.com/g/orthanc-users/c/r2LoAp72AWI/m/cVaFXopUBAAJ
+       **/
       $.ajax({
         url: url,
         type: 'POST',
-        dataType: 'text',
-        data: pageData.uuid,
-        async: true,  // Necessary to block UI
-        beforeSend: function() {
-          $.blockUI({ message: $(loading) });
-        },
-        complete: function(s) {
-          $.unblockUI();
-        },
-        success: function(s) {
+        data: JSON.stringify({
+          'Synchronous' : false,
+          'Resources' : [ pageData.uuid ]
+        }),
+        dataType: 'json',
+        async: false,
+        success: function(job) {
+          window.location.assign('explorer.html#job?uuid=' + job.ID);
         },
         error: function() {
           alert('Error during store');
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/Orthanc-1.9.5/OrthancServer/OrthancExplorer/query-retrieve.js 
new/Orthanc-1.9.6/OrthancServer/OrthancExplorer/query-retrieve.js
--- old/Orthanc-1.9.5/OrthancServer/OrthancExplorer/query-retrieve.js   
2021-07-08 09:44:49.000000000 +0200
+++ new/Orthanc-1.9.6/OrthancServer/OrthancExplorer/query-retrieve.js   
2021-07-21 10:26:20.000000000 +0200
@@ -31,6 +31,11 @@
  **/
 
 
+function IsoToDicomDate(s)
+{
+  return s.substring(0, 4) + s.substring(5, 7) + s.substring(8, 10);
+}
+
 function GenerateDicomDate(days)
 {
   var today = new Date();
@@ -48,8 +53,7 @@
   var timezoneOffset = today.getTimezoneOffset() * 60 * 1000;
   var localDate = new Date(utc.getTime() - timezoneOffset);
   
-  var s = localDate.toISOString();
-  return s.substring(0, 4) + s.substring(5, 7) + s.substring(8, 10);
+  return IsoToDicomDate(localDate.toISOString());
 }
 
 
@@ -85,7 +89,19 @@
   targetDate.append($('<option>').attr('value', GenerateDicomDate(-31) + 
'-').text('Last 31 days'));
   targetDate.append($('<option>').attr('value', GenerateDicomDate(-31 * 3) + 
'-').text('Last 3 months'));
   targetDate.append($('<option>').attr('value', GenerateDicomDate(-365) + 
'-').text('Last year'));
+  targetDate.append($('<option>').attr('value', 'specific').text('Specific 
date'));
   targetDate.selectmenu('refresh');
+
+  $('#qr-date-specific').hide();
+});
+
+
+$('#qr-date').live('change', function() {
+  if ($(this).val() == 'specific') {
+    $('#qr-date-specific').show();
+  } else {
+    $('#qr-date-specific').hide();
+  }
 });
 
 
@@ -120,7 +136,12 @@
 
 
 $('#qr-submit').live('click', function() {
-  var query, server, modalities, field;
+  var query, server, modalities, field, studyDate;
+
+  studyDate = $('#qr-date').val();
+  if (studyDate == 'specific') {
+    studyDate = IsoToDicomDate($('#qr-date-specific').val());
+  }
 
   query = {
     'Level' : 'Study',
@@ -130,7 +151,7 @@
       'PatientID' : '',
       'PatientName' : '',
       'PatientSex' : '',
-      'StudyDate' : $('#qr-date').val(),
+      'StudyDate' : studyDate,
       'StudyDescription' : ''
     }
   };
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/Orthanc-1.9.5/OrthancServer/Plugins/Include/orthanc/OrthancCPlugin.h 
new/Orthanc-1.9.6/OrthancServer/Plugins/Include/orthanc/OrthancCPlugin.h
--- old/Orthanc-1.9.5/OrthancServer/Plugins/Include/orthanc/OrthancCPlugin.h    
2021-07-08 09:44:49.000000000 +0200
+++ new/Orthanc-1.9.6/OrthancServer/Plugins/Include/orthanc/OrthancCPlugin.h    
2021-07-21 10:26:20.000000000 +0200
@@ -7501,9 +7501,9 @@
    * @param context The Orthanc plugin context, as received by 
OrthancPluginInitialize().
    * @param pathRegularExpression Regular expression for the URI. May contain 
groups. 
    * @param getHandler The callback function to handle REST calls using the 
GET HTTP method.
-   * @param postHandler The callback function to handle REST calls using the 
GET POST method.
-   * @param deleteHandler The callback function to handle REST calls using the 
GET DELETE method.
-   * @param putHandler The callback function to handle REST calls using the 
GET PUT method.
+   * @param postHandler The callback function to handle REST calls using the 
POST HTTP method.
+   * @param deleteHandler The callback function to handle REST calls using the 
DELETE HTTP method.
+   * @param putHandler The callback function to handle REST calls using the 
PUT HTTP method.
    * @param addChunk The callback invoked when a new chunk is available for 
the request body of a POST or PUT call.
    * @param execute The callback invoked once the entire body of a POST or PUT 
call is read.
    * @param finalize The callback invoked to release the resources associated 
with a POST or PUT call.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/Orthanc-1.9.5/OrthancServer/Resources/Configuration.json 
new/Orthanc-1.9.6/OrthancServer/Resources/Configuration.json
--- old/Orthanc-1.9.5/OrthancServer/Resources/Configuration.json        
2021-07-08 09:44:49.000000000 +0200
+++ new/Orthanc-1.9.6/OrthancServer/Resources/Configuration.json        
2021-07-21 10:26:20.000000000 +0200
@@ -680,7 +680,8 @@
   "MediaArchiveSize" : 1,
 
   // Performance setting to specify how Orthanc accesses the storage
-  // area during C-FIND. Three modes are available: (1) "Always"
+  // area during find operations (C-FIND, /tools/find API route and
+  // QIDO-RS in dicom-web). Three modes are available: (1) "Always"
   // allows Orthanc to read the storage area as soon as it needs an
   // information that is not present in its database (slowest mode),
   // (2) "Never" prevents Orthanc from accessing the storage area, and
@@ -797,7 +798,7 @@
   // identifier is only useful in the case of multiple
   // readers/writers, in order to avoid collisions between multiple
   // Orthanc servers. If unset, this identifier is taken as a SHA-1
-  // hash derived from the MAC adddresses of the network interfaces,
+  // hash derived from the MAC addresses of the network interfaces,
   // and from the AET and TCP ports used by Orthanc. Manually setting
   // this option is needed in Docker/Kubernetes environments. (new in
   // Orthanc 1.9.2)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/Orthanc-1.9.5/OrthancServer/Resources/Samples/ImportDicomFiles/ImportDicomFiles.py
 
new/Orthanc-1.9.6/OrthancServer/Resources/Samples/ImportDicomFiles/ImportDicomFiles.py
--- 
old/Orthanc-1.9.5/OrthancServer/Resources/Samples/ImportDicomFiles/ImportDicomFiles.py
      2021-07-08 09:44:49.000000000 +0200
+++ 
new/Orthanc-1.9.6/OrthancServer/Resources/Samples/ImportDicomFiles/ImportDicomFiles.py
      2021-07-21 10:26:20.000000000 +0200
@@ -19,11 +19,12 @@
 # along with this program. If not, see <http://www.gnu.org/licenses/>.
 
 
+import base64
+import httplib2
+import json
 import os
-import sys
 import os.path
-import httplib2
-import base64
+import sys
 
 if len(sys.argv) != 4 and len(sys.argv) != 6:
     print("""
@@ -40,23 +41,42 @@
 
 URL = 'http://%s:%d/instances' % (sys.argv[1], int(sys.argv[2]))
 
-success_count = 0
+dicom_count = 0
+json_count = 0
 total_file_count = 0
 
 
+def IsJson(content):
+    try:
+        if (sys.version_info >= (3, 0)):
+            json.loads(content.decode())
+            return True
+        else:
+            json.loads(content)
+            return True
+    except:
+        return False
+
+
 # This function will upload a single file to Orthanc through the REST API
 def UploadFile(path):
-    global success_count
+    global dicom_count
+    global json_count
     global total_file_count
 
-    f = open(path, "rb")
+    f = open(path, 'rb')
     content = f.read()
     f.close()
     total_file_count += 1
 
-    try:
-        sys.stdout.write("Importing %s" % path)
+    sys.stdout.write('Importing %s' % path)
+
+    if IsJson(content):
+        sys.stdout.write(' => ignored JSON file\n')
+        json_count += 1
+        return
 
+    try:
         h = httplib2.Http()
 
         headers = { 'content-type' : 'application/dicom' }
@@ -73,24 +93,24 @@
             # not always work)
             # http://en.wikipedia.org/wiki/Basic_access_authentication
             creds_str = username + ':' + password
-            creds_str_bytes = creds_str.encode("ascii")
+            creds_str_bytes = creds_str.encode('ascii')
             creds_str_bytes_b64 = b'Basic ' + base64.b64encode(creds_str_bytes)
-            headers['authorization'] = creds_str_bytes_b64.decode("ascii")
+            headers['authorization'] = creds_str_bytes_b64.decode('ascii')
 
         resp, content = h.request(URL, 'POST', 
                                   body = content,
                                   headers = headers)
 
         if resp.status == 200:
-            sys.stdout.write(" => success\n")
-            success_count += 1
+            sys.stdout.write(' => success\n')
+            dicom_count += 1
         else:
-            sys.stdout.write(" => failure (Is it a DICOM file? Is there a 
password?)\n")
+            sys.stdout.write(' => failure (Is it a DICOM file? Is there a 
password?)\n')
 
     except:
         type, value, traceback = sys.exc_info()
         sys.stderr.write(str(value))
-        sys.stdout.write(" => unable to connect (Is Orthanc running? Is there 
a password?)\n")
+        sys.stdout.write(' => unable to connect (Is Orthanc running? Is there 
a password?)\n')
 
 
 if os.path.isfile(sys.argv[3]):
@@ -102,7 +122,13 @@
         for f in files:
             UploadFile(os.path.join(root, f))
 
-if success_count == total_file_count:
-    print("\nSummary: all %d DICOM file(s) have been imported successfully" % 
success_count)
+
+if dicom_count + json_count == total_file_count:
+    print('\nSUCCESS: %d DICOM file(s) have been successfully imported' % 
dicom_count)
 else:
-    print("\nSummary: %d out of %d files have been imported successfully as 
DICOM instances" % (success_count, total_file_count))
+    print('\nWARNING: Only %d out of %d file(s) have been successfully 
imported as DICOM instance(s)' % (dicom_count, total_file_count - json_count))
+
+if json_count != 0:
+    print('NB: %d JSON file(s) have been ignored' % json_count)
+
+print('')
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/Orthanc-1.9.5/OrthancServer/Resources/Samples/ImportDicomFiles/OrthancImport.py
 
new/Orthanc-1.9.6/OrthancServer/Resources/Samples/ImportDicomFiles/OrthancImport.py
--- 
old/Orthanc-1.9.5/OrthancServer/Resources/Samples/ImportDicomFiles/OrthancImport.py
 2021-07-08 09:44:49.000000000 +0200
+++ 
new/Orthanc-1.9.6/OrthancServer/Resources/Samples/ImportDicomFiles/OrthancImport.py
 2021-07-21 10:26:20.000000000 +0200
@@ -22,6 +22,7 @@
 import argparse
 import bz2
 import gzip
+import json
 import os
 import requests
 import sys
@@ -71,12 +72,31 @@
 
 IMPORTED_STUDIES = set()
 COUNT_ERROR = 0
-COUNT_SUCCESS = 0
-        
+COUNT_DICOM = 0
+COUNT_JSON = 0
+
+
+def IsJson(content):
+    try:
+        if (sys.version_info >= (3, 0)):
+            json.loads(content.decode())
+            return True
+        else:
+            json.loads(content)
+            return True
+    except:
+        return False
+
+
 def UploadBuffer(dicom):
     global IMPORTED_STUDIES
     global COUNT_ERROR
-    global COUNT_SUCCESS
+    global COUNT_DICOM
+    global COUNT_JSON
+
+    if IsJson(dicom):
+        COUNT_JSON += 1
+        return
     
     auth = HTTPBasicAuth(args.username, args.password)
     r = requests.post('%s/instances' % args.url, auth = auth, data = dicom)
@@ -93,7 +113,7 @@
             raise
         
     info = r.json()
-    COUNT_SUCCESS += 1
+    COUNT_DICOM += 1
 
     if not info['ParentStudy'] in IMPORTED_STUDIES:
         IMPORTED_STUDIES.add(info['ParentStudy'])
@@ -219,8 +239,14 @@
         
 
 print('')
-print('Status:')
-print('  %d DICOM instances properly imported' % COUNT_SUCCESS)
+
+if COUNT_ERROR == 0:
+    print('SUCCESS:')
+else:
+    print('WARNING:')
+    
+print('  %d DICOM instances properly imported' % COUNT_DICOM)
 print('  %d DICOM studies properly imported' % len(IMPORTED_STUDIES))
+print('  %d JSON files ignored' % COUNT_JSON)
 print('  Error in %d files' % COUNT_ERROR)
 print('')
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/Orthanc-1.9.5/OrthancServer/Sources/OrthancRestApi/OrthancRestArchive.cpp 
new/Orthanc-1.9.6/OrthancServer/Sources/OrthancRestApi/OrthancRestArchive.cpp
--- 
old/Orthanc-1.9.5/OrthancServer/Sources/OrthancRestApi/OrthancRestArchive.cpp   
    2021-07-08 09:44:49.000000000 +0200
+++ 
new/Orthanc-1.9.6/OrthancServer/Sources/OrthancRestApi/OrthancRestArchive.cpp   
    2021-07-21 10:26:20.000000000 +0200
@@ -502,7 +502,7 @@
       .SetRequestField("Synchronous", RestApiCallDocumentation::Type_Boolean,
                        "If `true`, create the archive in synchronous mode, 
which means that the HTTP answer will directly "
                        "contain the ZIP file. This is the default, easy 
behavior. However, if global configuration option "
-                       "\"SynchronousZipStream\" is set to \"false\", 
asynchronous transfers should be prefered for "
+                       "\"SynchronousZipStream\" is set to \"false\", 
asynchronous transfers should be preferred for "
                        "large amount of data, as the creation of the temporary 
file might lead to network timeouts.", false)
       .SetRequestField("Asynchronous", RestApiCallDocumentation::Type_Boolean,
                        "If `true`, create the archive in asynchronous mode, 
which means that a job is submitted to create "
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/Orthanc-1.9.5/OrthancServer/Sources/ServerContext.cpp 
new/Orthanc-1.9.6/OrthancServer/Sources/ServerContext.cpp
--- old/Orthanc-1.9.5/OrthancServer/Sources/ServerContext.cpp   2021-07-08 
09:44:49.000000000 +0200
+++ new/Orthanc-1.9.6/OrthancServer/Sources/ServerContext.cpp   2021-07-21 
10:26:20.000000000 +0200
@@ -1174,16 +1174,25 @@
     StorageAccessor accessor(area_, GetMetricsRegistry());
     FileInfo attachment = accessor.Write(data, size, attachmentType, 
compression, storeMD5_);
 
-    StoreStatus status = index_.AddAttachment(
-      newRevision, attachment, resourceId, hasOldRevision, oldRevision, 
oldMD5);
-    if (status != StoreStatus_Success)
+    try
     {
-      accessor.Remove(attachment);
-      return false;
+      StoreStatus status = index_.AddAttachment(
+        newRevision, attachment, resourceId, hasOldRevision, oldRevision, 
oldMD5);
+      if (status != StoreStatus_Success)
+      {
+        accessor.Remove(attachment);
+        return false;
+      }
+      else
+      {
+        return true;
+      }
     }
-    else
+    catch (OrthancException&)
     {
-      return true;
+      // Fixed in Orthanc 1.9.6
+      accessor.Remove(attachment);
+      throw;
     }
   }
 

Reply via email to