Merge lp:~lamont/maas/atomic-delete-1.8 into lp:maas/1.8

Proposed by LaMont Jones
Status: Merged
Approved by: LaMont Jones
Approved revision: no longer in the source branch.
Merged at revision: 4055
Proposed branch: lp:~lamont/maas/atomic-delete-1.8
Merge into: lp:maas/1.8
Diff against target: 27 lines (+4/-2)
2 files modified
src/provisioningserver/utils/fs.py (+2/-1)
src/provisioningserver/utils/tests/test_fs.py (+2/-1)
To merge this branch: bzr merge lp:~lamont/maas/atomic-delete-1.8
Reviewer Review Type Date Requested Status
LaMont Jones (community) Approve
Review via email: mp+274456@code.launchpad.net

Commit message

Have atomic_delete use the same directory for the removal, like it claims to. This avoids failures do to cross-device links in rename().

Description of the change

Backport from trunk:

Have atomic_delete use the same directory for the removal, like it claims to. This avoids failures do to cross-device links in rename().

To post a comment you must log in.
Revision history for this message
MAAS Lander (maas-lander) wrote :

Voting does not meet specified criteria. Required: Approve >= 1, Disapprove == 0. Got: 1 Pending.

Revision history for this message
LaMont Jones (lamont) wrote :

trivial backport

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/provisioningserver/utils/fs.py'
2--- src/provisioningserver/utils/fs.py 2015-08-15 00:26:15 +0000
3+++ src/provisioningserver/utils/fs.py 2015-10-14 19:54:49 +0000
4@@ -142,7 +142,8 @@
5 will be on the same filesystem as the destination) and then deletes the
6 temporary file. Such a rename is atomic in POSIX.
7 """
8- del_filename = ".%s.del" % os.path.basename(filename)
9+ del_filename = "%s/.%s.del" % (
10+ os.path.dirname(filename), os.path.basename(filename))
11 rename(filename, del_filename)
12 os.remove(del_filename)
13
14
15=== modified file 'src/provisioningserver/utils/tests/test_fs.py'
16--- src/provisioningserver/utils/tests/test_fs.py 2015-08-17 15:42:00 +0000
17+++ src/provisioningserver/utils/tests/test_fs.py 2015-10-14 19:54:49 +0000
18@@ -190,7 +190,8 @@
19
20 def test_renames_file_before_deleting(self):
21 filename = self.make_file()
22- del_filename = ".%s.del" % os.path.basename(filename)
23+ del_filename = "%s/.%s.del" % (
24+ os.path.dirname(filename), os.path.basename(filename))
25 self.addCleanup(os.remove, del_filename)
26 mock_remove = self.patch(fs_module.os, "remove")
27 atomic_delete(filename)

Subscribers

People subscribed via source and target branches

to all changes: