diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-04-29 23:07:27 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-04-29 23:07:27 +0100 |
| commit | 3155b285e8260329a835de8c057f4a4cc9a5dcbd (patch) | |
| tree | 0e1660e219936466f6880e7b9c1140d14800f662 /src/lib | |
| parent | a85c82137ec26124ebefccb4aeebb96a3cdb8a4c (diff) | |
Hand-apply 0faa096dd8e3f8a5ba3975a88aaf6d1994866604 from master; improve disk space check wrt hard links.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/film.cc | 23 | ||||
| -rw-r--r-- | src/lib/film.h | 2 |
2 files changed, 22 insertions, 3 deletions
diff --git a/src/lib/film.cc b/src/lib/film.cc index 5e08ed997..3cdaeb48a 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -1101,10 +1101,29 @@ Film::required_disk_space () const * Note: the decision made by this method isn't, of course, 100% reliable. */ bool -Film::should_be_enough_disk_space (double& required, double& available) const -{ +Film::should_be_enough_disk_space (double& required, double& available, bool& can_hard_link) const +{ + /* Create a test file and see if we can hard-link it */ + boost::filesystem::path test = internal_video_mxf_dir() / "test"; + boost::filesystem::path test2 = internal_video_mxf_dir() / "test2"; + can_hard_link = true; + FILE* f = fopen_boost (test, "w"); + if (f) { + fclose (f); + boost::system::error_code ec; + boost::filesystem::create_hard_link (test, test2, ec); + if (ec) { + can_hard_link = false; + } + boost::filesystem::remove (test); + boost::filesystem::remove (test2); + } + boost::filesystem::space_info s = boost::filesystem::space (internal_video_mxf_dir ()); required = double (required_disk_space ()) / 1073741824.0f; + if (!can_hard_link) { + required *= 2; + } available = double (s.available) / 1073741824.0f; return (available - required) > 1; } diff --git a/src/lib/film.h b/src/lib/film.h index 5eb4f17ed..3cd370a0d 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -107,7 +107,7 @@ public: int audio_frame_rate () const; uint64_t required_disk_space () const; - bool should_be_enough_disk_space (double &, double &) const; + bool should_be_enough_disk_space (double& required, double& available, bool& can_hard_link) const; /* Proxies for some Playlist methods */ |
