summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2022-09-01 20:32:32 +0200
committerGitHub <noreply@github.com>2022-09-01 20:32:32 +0200
commit4a7667796b48f75a66424332c8da52fcd5eae45f (patch)
treec02cb3a288f67987cb200f95856258eebc7b313d
parentc8dad45c8afa4fd4a784ae6cdffb84a2e804084e (diff)
parent28cf6fee14d3bc5f6eda2099c7eb36e43297a8a8 (diff)
downloadvyatta-cfg-4a7667796b48f75a66424332c8da52fcd5eae45f.tar.gz
vyatta-cfg-4a7667796b48f75a66424332c8da52fcd5eae45f.zip
Merge pull request #49 from sempervictus/bug/T4607-copy_file_exedev
T4607: Fallthrough to simple stream copy when Boost's copy_file fails
-rw-r--r--debian/changelog6
-rw-r--r--src/cstore/unionfs/cstore-unionfs.cpp23
2 files changed, 26 insertions, 3 deletions
diff --git a/debian/changelog b/debian/changelog
index 5dcca6e..dfd15d7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+vyatta-cfg (0.102.0+vyos2+current5) unstable; urgency=medium
+
+ * Provide internal stream_copy fall-through for Boost's copy_file
+
+ -- Boris Lukashev <rageltman@sempervictus.com> Sat, 13 Aug 2022 19:00:00 -0500
+
vyatta-cfg (0.102.0+vyos2+current4) unstable; urgency=medium
* Adjust for replacement of Quagga with FRR.
diff --git a/src/cstore/unionfs/cstore-unionfs.cpp b/src/cstore/unionfs/cstore-unionfs.cpp
index e713dbd..e9aa7b2 100644
--- a/src/cstore/unionfs/cstore-unionfs.cpp
+++ b/src/cstore/unionfs/cstore-unionfs.cpp
@@ -167,6 +167,14 @@ _unescape_path_name(const string& path)
return npath;
}
+// Fall-through for Boost's filesystem::copy_file "complexity"
+void stream_file( const char* srce_file, const char* dest_file )
+{
+ std::ifstream srce( srce_file, std::ios::binary ) ;
+ std::ofstream dest( dest_file, std::ios::binary ) ;
+ dest << srce.rdbuf() ;
+}
+
vector<int> getActiveCommits()
{
string process_name = "vbash";
@@ -322,7 +330,6 @@ UnionfsCstore::~UnionfsCstore()
{
}
-
////// public virtual functions declared in base class
bool
UnionfsCstore::markSessionUnsaved()
@@ -750,7 +757,12 @@ UnionfsCstore::sync_dir(const FsPath& src, const FsPath& dst,
try {
if (path_is_regular(s)) {
// it's file
- b_fs::copy_file(s.path_cstr(), d.path_cstr());
+ try {
+ b_fs::copy_file(s.path_cstr(), d.path_cstr());
+ } catch (const boost::filesystem::filesystem_error& e) {
+ output_internal("syncdir failed due to %s in copy_file. Falling back to internal stream_file\n", e.what());
+ stream_file(s.path_cstr(), d.path_cstr());
+ }
} else {
// dir
recursive_copy_dir(s, d, true);
@@ -1592,7 +1604,12 @@ UnionfsCstore::recursive_copy_dir(const FsPath& src, const FsPath& dst,
}
}
}
- b_fs::copy_file(di->path(), nname);
+ try {
+ b_fs::copy_file(di->path(), nname);
+ } catch (const b_fs::filesystem_error& e) {
+ output_internal("recursive_copy_dir failed due to %s in copy_file. Falling back to internal stream_file\n", e.what());
+ stream_file(di->path().string().c_str(), nname.c_str());
+ }
}
}
}