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
1=== modified file 'usbcreator/backends/udisks/backend.py'
2--- usbcreator/backends/udisks/backend.py 2015-01-17 00:03:17 +0000
3+++ usbcreator/backends/udisks/backend.py 2015-02-19 06:53:06 +0000
4@@ -24,6 +24,7 @@
5 self.mounted_source = ''
6 self.formatting = []
7 self.handles = []
8+ self.new_parts = set()
9 self.show_all = show_all
10 self.allow_system_internal = allow_system_internal
11 logging.debug('UDisks2Backend')
12@@ -151,6 +152,7 @@
13 parent = partition.get_cached_property('Table').get_string()
14 fs = obj.get_filesystem()
15 if fs:
16+ self.new_parts.add((obj, block, drive, path))
17 mount_points = fs.get_cached_property('MountPoints').get_bytestring_array()
18 if (
19 fstype == 'vfat' and
20@@ -290,6 +292,24 @@
21 dev = p
22 self.targets[dev]['formatting'] = False
23 self.formatting.remove(dev)
24+ # try to mount and update the free spaces
25+ for obj,block,drive,path in self.new_parts:
26+ fstype = block.get_cached_property('IdType').get_string()
27+ fs = obj.get_filesystem()
28+ mount_points = fs.get_cached_property('MountPoints').get_bytestring_array()
29+ if (fstype == 'vfat' and len(mount_points) == 0):
30+ try:
31+ mount = self.retry_mount(fs)
32+ except:
33+ logging.exception('Could not mount the device: %s' % path)
34+ continue
35+ else:
36+ mount = mount_points and mount_points[0]
37+ if mount:
38+ total, free = misc.fs_size(mount)
39+ if total > 1:
40+ self._update_free(path)
41+ self.new_parts.clear()
42
43 def format_ended(self, dev=None):
44 self.format_done(dev)

Subscribers

People subscribed via source and target branches

to all changes: