Hand-apply 0faa096dd8e3f8a5ba3975a88aaf6d1994866604 from master; improve disk space...
authorCarl Hetherington <cth@carlh.net>
Wed, 29 Apr 2015 22:07:27 +0000 (23:07 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 29 Apr 2015 22:07:27 +0000 (23:07 +0100)
ChangeLog
src/lib/film.cc
src/lib/film.h
src/tools/dcpomatic.cc

index c989f549f8cb4636afc981e5c8bf5e4834975f15..88dde9c02bee9213c05ddbd741c1691c70bff963 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2015-04-29  Carl Hetherington  <cth@carlh.net>
 
+       * Make disk space check take account of whether hard links
+       are supported by the target filesystem (#511).
+
        * Allow configuration of the encryption key (from master).
 
        * Various fixes to bad timeline drag behaviour when
index 5e08ed9979844500c9e16b6f979c93c4edb32919..3cdaeb48aa0536af7f6d6b5e9dcc38874fcfa28e 100644 (file)
@@ -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;
 }
index 5eb4f17ed40be1681feb8819f2ffddd4935979c2..3cd370a0d109a753c14314592346518208f3fae2 100644 (file)
@@ -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 */
 
index 3151b5e1168d8f05b8d9794724c1b620adcc1643..221044afaa6ce71dd0ac522a1cd562ddb1ee8325 100644 (file)
@@ -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;
                        }
                }