summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-04-29 23:07:27 +0100
committerCarl Hetherington <cth@carlh.net>2015-04-29 23:07:27 +0100
commit3155b285e8260329a835de8c057f4a4cc9a5dcbd (patch)
tree0e1660e219936466f6880e7b9c1140d14800f662 /src
parenta85c82137ec26124ebefccb4aeebb96a3cdb8a4c (diff)
Hand-apply 0faa096dd8e3f8a5ba3975a88aaf6d1994866604 from master; improve disk space check wrt hard links.
Diffstat (limited to 'src')
-rw-r--r--src/lib/film.cc23
-rw-r--r--src/lib/film.h2
-rw-r--r--src/tools/dcpomatic.cc11
3 files changed, 31 insertions, 5 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 */
diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc
index 3151b5e11..221044afa 100644
--- a/src/tools/dcpomatic.cc
+++ b/src/tools/dcpomatic.cc
@@ -402,9 +402,16 @@ private:
{
double required;
double available;
+ bool can_hard_link;
- if (!_film->should_be_enough_disk_space (required, available)) {
- if (!confirm_dialog (this, wxString::Format (_("The DCP for this film will take up about %.1f Gb, and the disk that you are using only has %.1f Gb available. Do you want to continue anyway?"), required, available))) {
+ if (!_film->should_be_enough_disk_space (required, available, can_hard_link)) {
+ wxString message;
+ if (can_hard_link) {
+ message = wxString::Format (_("The DCP for this film will take up about %.1f Gb, and the disk that you are using only has %.1f Gb available. Do you want to continue anyway?"), required, available);
+ } else {
+ message = wxString::Format (_("The DCP and intermediate files for this film will take up about %.1f Gb, and the disk that you are using only has %.1f Gb available. You would need half as much space if the filesystem supported hard links, but it does not. Do you want to continue anyway?"), required, available);
+ }
+ if (!confirm_dialog (this, message)) {
return;
}
}