From 5f026c840cdcae98e1e3b60f3e07d27c87d18e2a Mon Sep 17 00:00:00 2001 From: James Turner Date: Fri, 2 Apr 2021 16:46:47 +0100 Subject: [PATCH] TerraSync: better reporting of permissions failures removing files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Log a ‘failed to remove orphan’ error as an error with the repository, instead of failing the entire sync --- simgear/io/HTTPRepository.cxx | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/simgear/io/HTTPRepository.cxx b/simgear/io/HTTPRepository.cxx index 0e70c98c..9b86ca63 100644 --- a/simgear/io/HTTPRepository.cxx +++ b/simgear/io/HTTPRepository.cxx @@ -393,7 +393,12 @@ public: // We now have a list of entries that need to be updated, and a list // of orphan files that should be removed. - removeOrphans(orphans); + try { + removeOrphans(orphans); + } catch (sg_exception& e) { + _repository->failedToUpdateChild(_relativePath, HTTPRepository::ResultCode::REPO_ERROR_IO); + } + scheduleUpdates(toBeUpdated); } @@ -405,11 +410,10 @@ public: void removeOrphans(const PathList orphans) { - PathList::const_iterator it; - for (it = orphans.begin(); it != orphans.end(); ++it) { - if (it->file() == ".dirindex") continue; - if (it->file() == ".hash") continue; - removeChild(*it); + for (const auto& o : orphans) { + if (o.file() == ".dirindex") continue; + if (o.file() == ".hash") continue; + removeChild(o); } } @@ -771,7 +775,7 @@ private: if (!ok) { SG_LOG(SG_TERRASYNC, SG_WARN, "removal failed for:" << path); - throw sg_io_exception("Failed to remove existing file/dir:", path); + throw sg_io_exception("Failed to remove existing file/dir:", path, _repository->basePath.utf8Str(), false); } }