diff --git a/unhide-dotpercent.py b/unhide-dotpercent.py index dfe63df..359ecb1 100755 --- a/unhide-dotpercent.py +++ b/unhide-dotpercent.py @@ -7,16 +7,17 @@ def walk(path): #print >> sys.stderr, path for f in os.listdir(path): fpath = os.path.join(path, f) + if os.path.isdir(fpath) and not os.path.islink(fpath): + walk(fpath) if f[0:2] == ".%": ff = f while ff[0:2] == ".%": ff = ff[2:] dest = os.path.join(path, ff) if not os.path.exists(dest): - print "i-have-moved -i '%s' '%s'" % (fpath.replace("'", "'\\''"), dest.replace("'", "'\\''")) + print "i-have-moved -i -- '%s' '%s'" % (fpath.replace("'", "'\\''"), dest.replace("'", "'\\''")) os.rename(fpath, dest) - if os.path.isdir(fpath) and not os.path.islink(fpath): - walk(fpath) + def help(): print 'Usage : %s directory' % sys.argv[0] sys.exit(1) diff --git a/updatehash.py b/updatehash.py index d73cd4f..2a389c1 100755 --- a/updatehash.py +++ b/updatehash.py @@ -66,8 +66,13 @@ def update(connection,cursor,path): connection.commit() print "commit!" print "cleaning up..." - cursor.execute("insert into removedfiles(rmtimestamp,tag,timestamp,path,md5,sha1,mtime,size) select ?,tag,timestamp,path,md5,sha1,mtime,size from files where path not in newfiles", (timestamp,)) - cursor.execute("delete from files where path not in (select path from newfiles)") + cursor.execute("create temp table deletedfiles(path)") + cursor.execute("create index i_deletedfiles_path on deletedfiles(path)") + likepath=('' + path).replace('%', '%%') + '%'; + cursor.execute("insert into deletedfiles(path) select path from files where path like ?", (likepath,)); + cursor.execute("delete from deletedfiles where path in newfiles"); + cursor.execute("insert into removedfiles(rmtimestamp,tag,timestamp,path,md5,sha1,mtime,size) select ?,tag,timestamp,path,md5,sha1,mtime,size from files where path in deletedfiles", (timestamp,)) + cursor.execute("delete from files where path in deletedfiles") connection.commit() def walk(db,path):