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
=== modified file 'filestore.py'
--- filestore.py 2011-10-07 06:41:59 +0000
+++ filestore.py 2011-10-09 08:06:24 +0000
@@ -583,6 +583,9 @@
583###########################################583###########################################
584# High performance IO and batch operations:584# High performance IO and batch operations:
585585
586def _can_skip(st):
587 return st.st_uid == 0 and st.st_gid == 0 and stat.S_IMODE(st.st_mode) == 0o700
588
586def iter_files(basedir):589def iter_files(basedir):
587 """590 """
588 Recursively iterate through files in directory *basedir*.591 Recursively iterate through files in directory *basedir*.
@@ -602,6 +605,8 @@
602 if stat.S_ISREG(st.st_mode):605 if stat.S_ISREG(st.st_mode):
603 yield File(fullname, st.st_size, st.st_mtime)606 yield File(fullname, st.st_size, st.st_mtime)
604 elif stat.S_ISDIR(st.st_mode):607 elif stat.S_ISDIR(st.st_mode):
608 if name == 'lost+found' and path.ismount(basedir) and _can_skip(st):
609 continue
605 dirs.append(fullname)610 dirs.append(fullname)
606 for fullname in dirs:611 for fullname in dirs:
607 for file in iter_files(fullname):612 for file in iter_files(fullname):

Subscribers

People subscribed via source and target branches