# HG changeset patch # User Sebastien Jodogne # Date 1367587389 -7200 # Node ID 47d63c94190285e148458122db27ffbd19f4c2b1 # Parent f1a0c472af7965f46189b95486f65d74d2f5b9e7 clearing /exports and /changes diff -r f1a0c472af79 -r 47d63c941902 NEWS --- a/NEWS Fri May 03 13:11:16 2013 +0200 +++ b/NEWS Fri May 03 15:23:09 2013 +0200 @@ -7,6 +7,7 @@ * Store-SCU for patients and studies in Orthanc Explorer * Filtering of incoming DICOM instances (through Lua scripting) * Filtering of incoming HTTP requests (through Lua scripting) +* Clearing of "/exports" and "/changes" * Check MD5 of third party downloads diff -r f1a0c472af79 -r 47d63c941902 OrthancServer/DatabaseWrapper.cpp --- a/OrthancServer/DatabaseWrapper.cpp Fri May 03 13:11:16 2013 +0200 +++ b/OrthancServer/DatabaseWrapper.cpp Fri May 03 15:23:09 2013 +0200 @@ -902,4 +902,10 @@ return 1; } } + + + void DatabaseWrapper::ClearTable(const std::string& tableName) + { + db_.Execute("DELETE FROM " + tableName); + } } diff -r f1a0c472af79 -r 47d63c941902 OrthancServer/DatabaseWrapper.h --- a/OrthancServer/DatabaseWrapper.h Fri May 03 13:11:16 2013 +0200 +++ b/OrthancServer/DatabaseWrapper.h Fri May 03 15:23:09 2013 +0200 @@ -212,5 +212,7 @@ } uint64_t IncrementGlobalSequence(GlobalProperty property); + + void ClearTable(const std::string& tableName); }; } diff -r f1a0c472af79 -r 47d63c941902 OrthancServer/OrthancRestApi.cpp --- a/OrthancServer/OrthancRestApi.cpp Fri May 03 13:11:16 2013 +0200 +++ b/OrthancServer/OrthancRestApi.cpp Fri May 03 15:23:09 2013 +0200 @@ -639,6 +639,14 @@ } + static void DeleteChanges(RestApi::DeleteCall& call) + { + RETRIEVE_CONTEXT(call); + context.GetIndex().DeleteChanges(); + call.GetOutput().AnswerBuffer("", "text/plain"); + } + + static void GetExports(RestApi::GetCall& call) { RETRIEVE_CONTEXT(call); @@ -656,6 +664,14 @@ } } + + static void DeleteExports(RestApi::DeleteCall& call) + { + RETRIEVE_CONTEXT(call); + context.GetIndex().DeleteExportedResources(); + call.GetOutput().AnswerBuffer("", "text/plain"); + } + // Get information about a single patient ----------------------------------- @@ -1483,7 +1499,9 @@ Register("/system", GetSystemInformation); Register("/statistics", GetStatistics); Register("/changes", GetChanges); + Register("/changes", DeleteChanges); Register("/exports", GetExports); + Register("/exports", DeleteExports); Register("/instances", UploadDicomFile); Register("/instances", ListResources); diff -r f1a0c472af79 -r 47d63c941902 OrthancServer/ServerIndex.cpp --- a/OrthancServer/ServerIndex.cpp Fri May 03 13:11:16 2013 +0200 +++ b/OrthancServer/ServerIndex.cpp Fri May 03 15:23:09 2013 +0200 @@ -1115,4 +1115,17 @@ transaction->Commit(); } + + + void ServerIndex::DeleteChanges() + { + boost::mutex::scoped_lock lock(mutex_); + db_->ClearTable("Changes"); + } + + void ServerIndex::DeleteExportedResources() + { + boost::mutex::scoped_lock lock(mutex_); + db_->ClearTable("ExportedResources"); + } } diff -r f1a0c472af79 -r 47d63c941902 OrthancServer/ServerIndex.h --- a/OrthancServer/ServerIndex.h Fri May 03 13:11:16 2013 +0200 +++ b/OrthancServer/ServerIndex.h Fri May 03 15:23:09 2013 +0200 @@ -161,5 +161,9 @@ void LogChange(ChangeType changeType, const std::string& publicId); + + void DeleteChanges(); + + void DeleteExportedResources(); }; } diff -r f1a0c472af79 -r 47d63c941902 Resources/Samples/Python/HighPerformanceAutoRouting.py --- a/Resources/Samples/Python/HighPerformanceAutoRouting.py Fri May 03 13:11:16 2013 +0200 +++ b/Resources/Samples/Python/HighPerformanceAutoRouting.py Fri May 03 15:23:09 2013 +0200 @@ -99,6 +99,10 @@ for instance in instances: RestToolbox.DoDelete('%s/instances/%s' % (URL, instance)) + # Clear the log of the exported instances (to prevent the + # SQLite database from growing indefinitely) + RestToolbox.DoDelete('%s/exports' % URL) + end = time.time() print 'The packet of %d instances has been sent in %d seconds' % (len(instances), end - start)