Mercurial > hg > orthanc
changeset 264:5b8e8b74bc8b
remove files only after the sqlite transaction has succeeded
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 07 Dec 2012 13:18:59 +0100 |
parents | 2354560daf2f |
children | a08dca15790e |
files | OrthancServer/ServerIndex.cpp |
diffstat | 1 files changed, 17 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancServer/ServerIndex.cpp Fri Dec 07 12:56:27 2012 +0100 +++ b/OrthancServer/ServerIndex.cpp Fri Dec 07 13:18:59 2012 +0100 @@ -59,6 +59,7 @@ bool hasRemainingLevel_; ResourceType remainingType_; std::string remainingPublicId_; + std::list<std::string> pendingFilesToRemove_; public: ServerIndexListener(ServerContext& context) : @@ -73,6 +74,17 @@ void Reset() { hasRemainingLevel_ = false; + pendingFilesToRemove_.clear(); + } + + void CommitFilesToRemove() + { + for (std::list<std::string>::iterator + it = pendingFilesToRemove_.begin(); + it != pendingFilesToRemove_.end(); it++) + { + context_.RemoveFile(*it); + } } virtual void SignalRemainingAncestor(ResourceType parentType, @@ -99,7 +111,7 @@ virtual void SignalFileDeleted(const std::string& fileUuid) { assert(Toolbox::IsUuid(fileUuid)); - context_.RemoveFile(fileUuid); + pendingFilesToRemove_.push_back(fileUuid); } bool HasRemainingLevel() const @@ -160,6 +172,10 @@ t->Commit(); + // We can remove the files once the SQLite transaction has been + // successfully committed + listener_->CommitFilesToRemove(); + return true; }