Merge lp:~jderose/filestore/lost+found into lp:filestore

Proposed by Jason Gerard DeRose
Status: Merged
Merged at revision: 222
Proposed branch: lp:~jderose/filestore/lost+found
Merge into: lp:filestore
Diff against target: 22 lines (+5/-0)
1 file modified
filestore.py (+5/-0)
To merge this branch: bzr merge lp:~jderose/filestore/lost+found
Reviewer Review Type Date Requested Status
dmedia Dev Pending
Review via email: mp+78749@code.launchpad.net

Description of the change

This changes iter_files() to no longer descend into the "lost+found" directory on ext4/ext3/ext2 filesystems. So that a normal "lost+found" directory isn't skipped by mistake, the criteria is quite strict.

Tiny change, but unfortunately rather impossible to write unit tests for (as we need specific a *filesystem* in a known state).

However, I will add a test for this to our long running test hardness once it's ready.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'filestore.py'
2--- filestore.py 2011-10-07 06:41:59 +0000
3+++ filestore.py 2011-10-09 08:06:24 +0000
4@@ -583,6 +583,9 @@
5 ###########################################
6 # High performance IO and batch operations:
7
8+def _can_skip(st):
9+ return st.st_uid == 0 and st.st_gid == 0 and stat.S_IMODE(st.st_mode) == 0o700
10+
11 def iter_files(basedir):
12 """
13 Recursively iterate through files in directory *basedir*.
14@@ -602,6 +605,8 @@
15 if stat.S_ISREG(st.st_mode):
16 yield File(fullname, st.st_size, st.st_mtime)
17 elif stat.S_ISDIR(st.st_mode):
18+ if name == 'lost+found' and path.ismount(basedir) and _can_skip(st):
19+ continue
20 dirs.append(fullname)
21 for fullname in dirs:
22 for file in iter_files(fullname):

Subscribers

People subscribed via source and target branches