This commit is contained in:
ville rantanen
2013-01-05 21:06:37 +02:00

View File

@@ -88,9 +88,11 @@ def add_recurse(options):
conn.text_factory=str conn.text_factory=str
db=conn.cursor() db=conn.cursor()
for path,dirs,files in os.walk(options.startpath,followlinks=options.symlinks): for path,dirs,files in os.walk(options.startpath,followlinks=options.symlinks):
print('Checking '+path)
dirs=clean_dirs(dirs) dirs=clean_dirs(dirs)
if not options.symlinks: if not options.symlinks:
files=clean_syms(files) files=clean_syms(files)
files.sort()
for file in files: for file in files:
if IMGMATCH.match(file): if IMGMATCH.match(file):
filename=os.path.abspath(os.path.join(path,file)) filename=os.path.abspath(os.path.join(path,file))
@@ -231,12 +233,16 @@ def confirm(prompt=None, resp=False):
if ans == 'n' or ans == 'N': if ans == 'n' or ans == 'N':
return False return False
def find_duplicates(sqlfile): def find_duplicates(sqlfile,search):
if (search=='.'):
search='%'
else:
search='%'+search+'%'
conn=sqlite3.connect(sqlfile) conn=sqlite3.connect(sqlfile)
conn.text_factory=str conn.text_factory=str
db=conn.cursor() db=conn.cursor()
dbh=conn.cursor() dbh=conn.cursor()
db.execute("SELECT hash,count(*) FROM list group by hash HAVING count(*) > 1 ") db.execute("SELECT hash,count(*) FROM list WHERE file LIKE ? group by hash HAVING count(*) > 1 ",(search,))
duphash=[] duphash=[]
for row in db: for row in db:
hash=row[0] hash=row[0]
@@ -298,7 +304,7 @@ def main():
print('Random lists...') print('Random lists...')
random_lists(options.sqlfile) random_lists(options.sqlfile)
if options.duplicate: if options.duplicate:
files=find_duplicates(options.sqlfile) files=find_duplicates(options.sqlfile,options.startpath)
print_dup_structure(files) print_dup_structure(files)
if options.searchsmall: if options.searchsmall:
files=find_smalls(options.minsize,options.sqlfile) files=find_smalls(options.minsize,options.sqlfile)