#include <lwext4/ext4_mkfs.h>
}
#include <boost/filesystem.hpp>
-#include <boost/foreach.hpp>
#include <string>
total_remaining -= this_time;
++progress_count;
- if ((progress_count % progress_frequency) == 0) {
+ if ((progress_count % progress_frequency) == 0 && nanomsg) {
nanomsg->send(String::compose(DISK_WRITER_COPY_PROGRESS "\n%1\n", (1 - float(total_remaining) / total)), SHORT_TIMEOUT);
}
}
digester.add (buffer, this_time);
remaining -= this_time;
total_remaining -= this_time;
- nanomsg->send(String::compose(DISK_WRITER_VERIFY_PROGRESS "\n%1\n", (1 - float(total_remaining) / total)), SHORT_TIMEOUT);
+ if (nanomsg) {
+ nanomsg->send(String::compose(DISK_WRITER_VERIFY_PROGRESS "\n%1\n", (1 - float(total_remaining) / total)), SHORT_TIMEOUT);
+ }
}
ext4_fclose (&in);
verify (vector<CopiedFile> const& copied_files, uint64_t total, Nanomsg* nanomsg)
{
uint64_t total_remaining = total;
- BOOST_FOREACH (CopiedFile const& i, copied_files) {
+ for (auto const& i: copied_files) {
string const read_digest = read (i.from, i.to, total_remaining, total, nanomsg);
LOG_DISK ("Read %1 %2 was %3 on write, now %4", i.from.string(), i.to.generic_string(), i.write_digest, read_digest);
if (read_digest != i.write_digest) {
}
+static
+void
+format_progress (void* context, float progress)
+{
+ if (context) {
+ reinterpret_cast<Nanomsg*>(context)->send(String::compose(DISK_WRITER_FORMAT_PROGRESS "\n%1\n", progress), SHORT_TIMEOUT);
+ }
+}
+
+
void
#ifdef DCPOMATIC_WINDOWS
dcpomatic::write (boost::filesystem::path dcp_path, string device, string, Nanomsg* nanomsg)
}
LOG_DISK_NC ("Opened partition");
- nanomsg->send(DISK_WRITER_FORMATTING "\n", SHORT_TIMEOUT);
-
- r = ext4_mkfs(&fs, bd, &info, F_SET_EXT2);
+ r = ext4_mkfs(&fs, bd, &info, F_SET_EXT2, format_progress, nanomsg);
if (r != EOK) {
throw CopyError ("Failed to make filesystem", r);
}
}
ext4_device_unregister("ext4_fs");
- if (!nanomsg->send(DISK_WRITER_OK "\n", LONG_TIMEOUT)) {
+ if (nanomsg && !nanomsg->send(DISK_WRITER_OK "\n", LONG_TIMEOUT)) {
throw CommunicationFailedError ();
}
disk_write_finished ();
} catch (CopyError& e) {
LOG_DISK("CopyError (from write): %1 %2", e.message(), e.number().get_value_or(0));
- nanomsg->send(String::compose(DISK_WRITER_ERROR "\n%1\n%2\n", e.message(), e.number().get_value_or(0)), LONG_TIMEOUT);
+ if (nanomsg) {
+ nanomsg->send(String::compose(DISK_WRITER_ERROR "\n%1\n%2\n", e.message(), e.number().get_value_or(0)), LONG_TIMEOUT);
+ }
} catch (VerifyError& e) {
LOG_DISK("VerifyError (from write): %1 %2", e.message(), e.number());
- nanomsg->send(String::compose(DISK_WRITER_ERROR "\n%1\n%2\n", e.message(), e.number()), LONG_TIMEOUT);
+ if (nanomsg) {
+ nanomsg->send(String::compose(DISK_WRITER_ERROR "\n%1\n%2\n", e.message(), e.number()), LONG_TIMEOUT);
+ }
} catch (exception& e) {
LOG_DISK("Exception (from write): %1", e.what());
- nanomsg->send(String::compose(DISK_WRITER_ERROR "\n%1\n0\n", e.what()), LONG_TIMEOUT);
+ if (nanomsg) {
+ nanomsg->send(String::compose(DISK_WRITER_ERROR "\n%1\n0\n", e.what()), LONG_TIMEOUT);
+ }
}