← Back to team overview

usb-creator-hackers team mailing list archive

[Merge] lp:~yuningdodo/usb-creator/usb-creator.lp1413494-auto-mount-after-format into lp:usb-creator

 

Yu Ning has proposed merging lp:~yuningdodo/usb-creator/usb-creator.lp1413494-auto-mount-after-format into lp:usb-creator.

Requested reviews:
  usb-creator hackers (usb-creator-hackers)
Related bugs:
  Bug #1413494 in usb-creator (Ubuntu): "Free partition space isn't correctly updated after erasing"
  https://bugs.launchpad.net/ubuntu/+source/usb-creator/+bug/1413494

For more details, see:
https://code.launchpad.net/~yuningdodo/usb-creator/usb-creator.lp1413494-auto-mount-after-format/+merge/250256

I checked the source code and found usb-creator can only calculate the free space for a mounted partition, however the newly formated partition isn't mounted.

So to fix the issue we could mount it automatically after the formating. In the attached patch this job is done in the dbus method Format() in usb-creator-helper. In my own test it works fine.

-- 
Your team usb-creator hackers is requested to review the proposed merge of lp:~yuningdodo/usb-creator/usb-creator.lp1413494-auto-mount-after-format into lp:usb-creator.
=== modified file 'bin/usb-creator-helper'
--- bin/usb-creator-helper	2014-09-02 20:12:12 +0000
+++ bin/usb-creator-helper	2015-02-19 05:17:59 +0000
@@ -231,7 +231,7 @@
             check_system_internal(dev)
 
         # TODO LOCK
-        unmount_all(udisks, dev)
+        unmount_all(udisks, parent_dev)
         # Do NOT use the disk if asked to format a partition.
         # We still need to obtain the disk device name to zero out the MBR
         part = dev.get_partition()
@@ -243,6 +243,9 @@
             part.call_set_type_sync('0x0c', no_options, None)
             part.call_set_flags_sync(boot_dos_flag, no_options, None)
             block.call_format_sync('vfat', GLib.Variant('a{sv}', {'label': GLib.Variant('s', '')}), None)
+
+            # Mount the partition for the frontend to calc free space
+            dev.get_filesystem().call_mount_sync(no_options, None)
         else:
             # Create a new partition table and a FAT partition.
             # Is this correct call to create partition table ?!
@@ -262,6 +265,11 @@
             block = obj.get_block()
             block.call_format_sync('vfat', GLib.Variant('a{sv}', {'label': GLib.Variant('s', '')}), None)
 
+            # Mount the partition for the frontend to calc free space
+            udisks = UDisks.Client.new_sync(None)
+            obj = udisks.get_object(partition)
+            obj.get_filesystem().call_mount_sync(no_options, None)
+
         # Zero out the MBR.  Will require fancy privileges.
         parent_block = parent_dev.get_block()
         parent_file = parent_block.get_cached_property('Device').get_bytestring().decode('utf-8')


Follow ups