Merge lp:~yuningdodo/usb-creator/usb-creator.lp1413494v2-update-free-space-after-format into lp:usb-creator

Proposed by Yu Ning on 2015-02-19
Status: Needs review
Proposed branch: lp:~yuningdodo/usb-creator/usb-creator.lp1413494v2-update-free-space-after-format
Merge into: lp:usb-creator
Diff against target: 44 lines (+20/-0)
1 file modified
usbcreator/backends/udisks/backend.py (+20/-0)
To merge this branch: bzr merge lp:~yuningdodo/usb-creator/usb-creator.lp1413494v2-update-free-space-after-format
Reviewer Review Type Date Requested Status
Brian Murray 2015-02-19 Pending
usb-creator hackers 2015-02-19 Pending
Review via email: mp+250258@code.launchpad.net

Description of the change

In usbcreator udisks backend it will try to mount the new partition and calculate the free space in the _udisks_partition_added() callback, however it will always skip the operation since the device is marked as "formatting".

To fix this issue we can keep the new partition in a list and do the job after formatting completed.

To post a comment you must log in.
463. By Yu Ning on 2015-02-19

Update free space after formatting. (LP: #1413494)

Yu Ning (yuningdodo) wrote :

Sorry, I forgot to commit my changes previously, the branch is updated now.

Unmerged revisions

463. By Yu Ning on 2015-02-19

Update free space after formatting. (LP: #1413494)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'usbcreator/backends/udisks/backend.py'
--- usbcreator/backends/udisks/backend.py 2015-01-17 00:03:17 +0000
+++ usbcreator/backends/udisks/backend.py 2015-02-19 06:53:06 +0000
@@ -24,6 +24,7 @@
24 self.mounted_source = ''24 self.mounted_source = ''
25 self.formatting = []25 self.formatting = []
26 self.handles = []26 self.handles = []
27 self.new_parts = set()
27 self.show_all = show_all28 self.show_all = show_all
28 self.allow_system_internal = allow_system_internal29 self.allow_system_internal = allow_system_internal
29 logging.debug('UDisks2Backend')30 logging.debug('UDisks2Backend')
@@ -151,6 +152,7 @@
151 parent = partition.get_cached_property('Table').get_string()152 parent = partition.get_cached_property('Table').get_string()
152 fs = obj.get_filesystem()153 fs = obj.get_filesystem()
153 if fs:154 if fs:
155 self.new_parts.add((obj, block, drive, path))
154 mount_points = fs.get_cached_property('MountPoints').get_bytestring_array()156 mount_points = fs.get_cached_property('MountPoints').get_bytestring_array()
155 if (157 if (
156 fstype == 'vfat' and158 fstype == 'vfat' and
@@ -290,6 +292,24 @@
290 dev = p292 dev = p
291 self.targets[dev]['formatting'] = False293 self.targets[dev]['formatting'] = False
292 self.formatting.remove(dev)294 self.formatting.remove(dev)
295 # try to mount and update the free spaces
296 for obj,block,drive,path in self.new_parts:
297 fstype = block.get_cached_property('IdType').get_string()
298 fs = obj.get_filesystem()
299 mount_points = fs.get_cached_property('MountPoints').get_bytestring_array()
300 if (fstype == 'vfat' and len(mount_points) == 0):
301 try:
302 mount = self.retry_mount(fs)
303 except:
304 logging.exception('Could not mount the device: %s' % path)
305 continue
306 else:
307 mount = mount_points and mount_points[0]
308 if mount:
309 total, free = misc.fs_size(mount)
310 if total > 1:
311 self._update_free(path)
312 self.new_parts.clear()
293313
294 def format_ended(self, dev=None):314 def format_ended(self, dev=None):
295 self.format_done(dev)315 self.format_done(dev)

Subscribers

People subscribed via source and target branches

to all changes: