aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bpkg/database11
-rw-r--r--bpkg/pkg-unpack.cxx4
2 files changed, 13 insertions, 2 deletions
diff --git a/bpkg/database b/bpkg/database
index c4ace56..05ffb04 100644
--- a/bpkg/database
+++ b/bpkg/database
@@ -17,6 +17,17 @@ namespace bpkg
database
open (const dir_path& configuration, tracer&, bool create = false);
+
+ struct tracer_guard
+ {
+ tracer_guard (database& db, tracer& t)
+ : db_ (db), t_ (db.tracer ()) {db.tracer (t);}
+ ~tracer_guard () {db_.tracer (*t_);}
+
+ private:
+ database& db_;
+ odb::tracer* t_;
+ };
}
#endif // BPKG_DATABASE
diff --git a/bpkg/pkg-unpack.cxx b/bpkg/pkg-unpack.cxx
index 6979842..463531f 100644
--- a/bpkg/pkg-unpack.cxx
+++ b/bpkg/pkg-unpack.cxx
@@ -28,7 +28,7 @@ namespace bpkg
pkg_unpack (database& db, const dir_path& c, const dir_path& d, bool purge)
{
tracer trace ("pkg_unpack(dir)");
- db.tracer (trace); // "Tail" call, never restored.
+ tracer_guard tg (db, trace);
if (!exists (d))
fail << "package directory " << d << " does not exist";
@@ -82,7 +82,7 @@ namespace bpkg
pkg_unpack (database& db, const dir_path& c, const string& name)
{
tracer trace ("pkg_unpack(pkg)");
- db.tracer (trace); // "Tail" call, never restored.
+ tracer_guard tg (db, trace);
transaction t (db.begin ());
shared_ptr<package> p (db.find<package> (name));